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


##########
datafusion/physical-expr-common/src/aggregate/mod.rs:
##########
@@ -292,16 +307,38 @@ impl AggregateExpr for AggregateFunctionExpr {
             is_distinct: self.is_distinct,
             input_type: &self.input_type,
             args_num: self.args.len(),
+            name: &self.name,
         };
         self.fun.groups_accumulator_supported(args)
     }
 
     fn create_groups_accumulator(&self) -> Result<Box<dyn GroupsAccumulator>> {
-        self.fun.create_groups_accumulator()
+        let args = AccumulatorArgs {
+            data_type: &self.data_type,
+            schema: &self.schema,
+            ignore_nulls: self.ignore_nulls,
+            sort_exprs: &self.sort_exprs,
+            is_distinct: self.is_distinct,
+            input_type: &self.input_type,
+            args_num: self.args.len(),
+            name: &self.name,
+        };
+        self.fun.create_groups_accumulator(args)
     }
 
     fn order_bys(&self) -> Option<&[PhysicalSortExpr]> {
-        (!self.ordering_req.is_empty()).then_some(&self.ordering_req)
+        if self.fun.has_ordering_requirements() && 
!self.ordering_req.is_empty() {
+            return Some(&self.ordering_req);
+        }
+        None

Review Comment:
   I found that most of the functions like Sum should not expect to get 
`ordering_req`, even it is non-empty.
   If `ordering_req` is returned, I will get unexpected expression here
   
   
https://github.com/apache/datafusion/blob/ea92ae72f7ec2e941d35aa077c6a39f74523ab63/datafusion/physical-plan/src/aggregates/mod.rs#L1011-L1013



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