-
Notifications
You must be signed in to change notification settings - Fork 1.6k
fix: Support aggregate expressions in QUALIFY
#17313
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
base: main
Are you sure you want to change the base?
Conversation
@Vedin can you please help review this PR? I see you are starting to do so on the original ticket #17210 (comment) |
In general, logic looks correct. The only unsupported thing is what I mentioned under the issue #17210 (comment) |
Ok((plan, select_exprs_post_aggr, having_expr_post_aggr)) | ||
// Rewrite the QUALIFY expression to use the columns produced by the | ||
// aggregation. | ||
let qualify_expr_post_aggr = if let Some(qualify_expr) = qualify_expr_opt { |
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.
nit: this logic is pretty similar to what is used for HAVING
. What about creating a helper function for this helper logic?
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.
Definitely similar, although currently we still require multiple distinct function calls to check_column_satisfy_expr
because for each expression (SELECT
, HAVING
, QUALIFY
), we pass in diagnostic information that indicates which clause the error occurs in (CheckColumnsSatisfyExprsPurpose
).
Given this, I'm not quite sure a helper function would help readability/redundancy too much
Which issue does this PR close?
QUALIFY
#17210.What changes are included in this PR?
QUALIFY
and rewrites any aggregates in theQUALIFY
clause to use column references (using the expression's schema name).Are these changes tested?
Yes
Are there any user-facing changes?
No additional features, just fixes.