comphead commented on issue #6139:
URL: 
https://github.com/apache/arrow-datafusion/issues/6139#issuecomment-1536917297

   @alamb @jackwener may I ask your help?  I have found why projection is not 
correct. push_down_projection never called for query like that 
   ```
   select 1 a group by a union all select 2 b
   ```
   
   However its called  for 
   ```
   select 1 a group by a union select 2 b
   ```
   
   The reason for that  UNION has another logical plan
   UNION
   ```
   | logical_plan  | Aggregate: groupBy=[[a]], aggr=[[]]                        
                                                          |
   |               |   Union                                                    
                                                          |
   |               |     Projection: Int64(1) AS a                              
                                                          |
   |               |       Aggregate: groupBy=[[Int64(1)]], aggr=[[]]           
                                                          |
   |               |         EmptyRelation                                      
                                                          |
   |               |     Projection: Int64(2) AS a                              
                                                          |
   |               |       EmptyRelation   
   ```
   
   UNION ALL
   ```
   | logical_plan  | Union                                                      
                                                  |
   |               |   Projection: Int64(1) AS a                                
                                                  |
   |               |     Aggregate: groupBy=[[Int64(1)]], aggr=[[]]             
                                                  |
   |               |       EmptyRelation                                        
                                                  |
   |               |   Projection: Int64(2) AS b                                
                                                  |
   |               |     EmptyRelation      
   ```
   
   UNION have a weird top Aggregate node, which looks strange for me. as 
Aggregation happens twice in that case, but because of that UNION 
push_down_projection works.
   
   I'm trying to understand the real rootcause if it in bad plan generated in 
the first place or bug in push_down_projection
   


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