-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
minor: revert parsing precedence between Aggr and UDAF #7682
Conversation
Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, thank you
I agree it makes sense to allow UDAF to shadow built in aggregate functions (so that users can redefine the meaning of aggregates if they wanted) Is there any way we can add a test to document this behavior? Perhaps in https://github.com/apache/arrow-datafusion/blob/3f8c51222fa0aa5bb4ef7fa5cab55875bfde0a63/datafusion/core/tests/user_defined/user_defined_aggregates.rs 🤔 |
Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
Thanks for reviewing!
Good suggestion 👍 I've added one in that file, reusing the existing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @waynexia
]; | ||
assert_batches_eq!(expected, &execute(&ctx, sql).await.unwrap()); | ||
|
||
// Register `TimeSum` with name `sum`. This will shadow the builtin one |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
* minor: revert parsing precedence between Aggr and UDAF Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * add unit test Signed-off-by: Ruihang Xia <waynestxia@gmail.com> --------- Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
Which issue does this PR close?
Closes #.
Rationale for this change
Just came across these lines that UDF is parsed before scalar function:
https://github.com/apache/arrow-datafusion/blob/bcc2acd8d10204b32b64fa3b77372655eaee8f06/datafusion/sql/src/expr/function.rs#L49-L61
And then find this rule doesn't hold for Aggr/UDAF
What changes are included in this PR?
After this patch, UDAF can shadow builtin AggrFn if they have the same name.
Are these changes tested?
n/a
Are there any user-facing changes?
It is... I think