jackwener opened a new issue #2045:
URL: https://github.com/apache/arrow-datafusion/issues/2045


   **Is your feature request related to a problem or challenge? Please describe 
what you are trying to do.**
   ```sql
   explain verbose select max(distinct(c1)) from test;
   
   
+-------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
   | plan_type                                             | plan               
                                                                                
                                         |
   
+-------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
   | initial_logical_plan                                  | Projection: 
#MAX(DISTINCT test.c1)                                                          
                                                |
   |                                                       |   Aggregate: 
groupBy=[[]], aggr=[[MAX(DISTINCT #test.c1)]]                                   
                                               |
   |                                                       |     TableScan: 
test projection=None                                                            
                                             |
   | logical_plan after simplify_expressions               | SAME TEXT AS ABOVE 
                                                                                
                                         |
   | logical_plan after eliminate_filter                   | SAME TEXT AS ABOVE 
                                                                                
                                         |
   | logical_plan after common_sub_expression_eliminate    | SAME TEXT AS ABOVE 
                                                                                
                                         |
   | logical_plan after eliminate_limit                    | SAME TEXT AS ABOVE 
                                                                                
                                         |
   | logical_plan after projection_push_down               | Projection: 
#MAX(DISTINCT test.c1)                                                          
                                                |
   |                                                       |   Aggregate: 
groupBy=[[]], aggr=[[MAX(DISTINCT #test.c1)]]                                   
                                               |
   |                                                       |     TableScan: 
test projection=Some([0])                                                       
                                             |
   | logical_plan after filter_push_down                   | SAME TEXT AS ABOVE 
                                                                                
                                         |
   | logical_plan after limit_push_down                    | SAME TEXT AS ABOVE 
                                                                                
                                         |
   | logical_plan after SingleDistinctAggregationToGroupBy | Projection: 
#MAX(DISTINCT test.c1)                                                          
                                                |
   |                                                       |   Projection: 
#MAX(alias1) AS MAX(DISTINCT test.c1)                                           
                                              |
   |                                                       |     Aggregate: 
groupBy=[[]], aggr=[[MAX(#alias1)]]                                             
                                             |
   |                                                       |       Aggregate: 
groupBy=[[#test.c1 AS alias1]], aggr=[[]]                                       
                                           |
   |                                                       |         TableScan: 
test projection=Some([0]) 
   ```
   
   **Describe the solution you'd like**
   Find the problem in `SingleDistinctAggregationToGroupBy` rule and fix it.
   
   **Describe alternatives you've considered**
   `SingleDistinctAggregationToGroupBy` rule make the plan more complex.
   
   **Additional context**
   None


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