alamb commented on code in PR #11611: URL: https://github.com/apache/datafusion/pull/11611#discussion_r1688700500
########## datafusion/expr/src/aggregate_function.rs: ########## @@ -37,8 +36,6 @@ pub enum AggregateFunction { Min, /// Maximum Max, - /// Aggregation into an array Review Comment: 🎉 ########## datafusion/physical-expr-common/src/aggregate/mod.rs: ########## @@ -573,8 +573,9 @@ impl AggregateExpr for AggregateFunctionExpr { }) .collect::<Vec<_>>(); let mut name = self.name().to_string(); - // TODO: Generalize order-by clause rewrite - if reverse_udf.name() == "ARRAY_AGG" { + // If the function is changed, we need to reverse order_by clause as well + // i.e. First(a order by b asc null first) -> Last(a order by b desc null last) + if self.fun().name() == reverse_udf.name() { Review Comment: I think it would be good to eventually move this to a method in `https://github.com/apache/datafusion/pull/11611` though I agree this is good for now. Maybe we can file a ticket to track -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org