jayzhan211 commented on code in PR #11611:
URL: https://github.com/apache/datafusion/pull/11611#discussion_r1687345718


##########
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 guess name checking is enough for now.
   
   Introduce `supports_rewrite_order_by` for AggregateUDFImpl might add 
additional complexity without benefit.



-- 
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

Reply via email to