You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "jayzhan211 (via GitHub)" <gi...@apache.org> on 2024/04/16 00:19:56 UTC

Re: [PR] Deprecate builtin first/last aggregate function and use UDAF [arrow-datafusion]

jayzhan211 commented on code in PR #10091:
URL: https://github.com/apache/arrow-datafusion/pull/10091#discussion_r1566568252


##########
datafusion/functions-aggregate/src/first_last.rs:
##########
@@ -99,19 +130,37 @@ impl AggregateUDFImpl for FirstValue {
         let mut all_sort_orders = vec![];
 
         // Construct PhysicalSortExpr objects from Expr objects:
+        // TODO: Reuse `create_physical_sort_expr`
         let mut sort_exprs = vec![];
         for expr in acc_args.sort_exprs {
-            if let Expr::Sort(sort) = expr {
-                if let Expr::Column(col) = sort.expr.as_ref() {
+            if let Expr::Sort(Sort {
+                expr,
+                asc,
+                nulls_first,
+            }) = expr
+            {
+                if let Expr::Column(col) = expr.as_ref() {
                     let name = &col.name;
                     let e = expressions::column::col(name, acc_args.schema)?;
                     sort_exprs.push(PhysicalSortExpr {
                         expr: e,
                         options: SortOptions {
-                            descending: !sort.asc,
-                            nulls_first: sort.nulls_first,
+                            descending: !asc,
+                            nulls_first: *nulls_first,
                         },
                     });
+                } else if let Expr::Alias(alias) = expr.as_ref() {

Review Comment:
   Filed #10074 to see how to arrange the code here, replace with `create_physical_sort_expr` or others



-- 
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-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org