Vedin commented on code in PR #17313:
URL: https://github.com/apache/datafusion/pull/17313#discussion_r2300932752
##########
datafusion/sql/src/select.rs:
##########
@@ -944,15 +963,41 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
check_columns_satisfy_exprs(
&column_exprs_post_aggr,
std::slice::from_ref(&having_expr_post_aggr),
- CheckColumnsSatisfyExprsPurpose::HavingMustReferenceAggregate,
+ CheckColumnsSatisfyExprsPurpose::Aggregate(
+ CheckColumnsMustReferenceAggregatePurpose::Having,
+ ),
)?;
Some(having_expr_post_aggr)
} else {
None
};
- 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 {
Review Comment:
nit: this logic is pretty similar to what is used for `HAVING`. What about
creating a helper function for this helper logic?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]