haohuaijin commented on code in PR #8266:
URL: https://github.com/apache/arrow-datafusion/pull/8266#discussion_r1402214863


##########
datafusion/optimizer/src/single_distinct_to_groupby.rs:
##########
@@ -64,22 +67,32 @@ fn is_single_distinct_agg(plan: &LogicalPlan) -> 
Result<bool> {
     match plan {
         LogicalPlan::Aggregate(Aggregate { aggr_expr, .. }) => {
             let mut fields_set = HashSet::new();
-            let mut distinct_count = 0;
+            let mut aggregate_count = 0;
             for expr in aggr_expr {
                 if let Expr::AggregateFunction(AggregateFunction {
-                    distinct, args, ..
+                    fun,
+                    distinct,
+                    args,
+                    filter,
+                    ..

Review Comment:
   thanks for this suggestion, `order_by` also results in an error, I will 
check it in the following commit.
   ```
   DataFusion CLI v33.0.0
   ❯ select sum(distinct c2 order by c2) from 
'../testing/data/csv/aggregate_test_100.csv';
   Optimizer rule 'push_down_projection' failed
   caused by
   Error during planning: required columns can't push down, columns: {Column { 
relation: None, name: "alias1" }, Column { relation: Some(Bare { table: 
"/home/hhj/agg.csv" }), name: "c2" }}
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to