jayzhan211 commented on code in PR #11611: URL: https://github.com/apache/datafusion/pull/11611#discussion_r1688971052
########## 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: Thanks @alamb I come out a better idea of adding `reverse_name` method instead of `supports_rewrite_order_by ` which makes more sense to me. #11629 -- 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