JasonLi-cn opened a new issue, #10280:
URL: https://github.com/apache/datafusion/issues/10280

   ### Is your feature request related to a problem or challenge?
   
   ```shell
   DataFusion CLI v37.1.0
   > select * from number;
   +----+----+----+
   | c0 | c1 | c2 |
   +----+----+----+
   | 1  | 2  | 3  |
   +----+----+----+
   1 row(s) fetched.
   Elapsed 0.005 seconds.
   
   > explain select c0 + 1, count(c0 + 1) from number group by c0 + 1;
   
+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | plan_type     | plan                                                       
                                                                                
                                                                                
                       |
   
+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | logical_plan  | Aggregate: groupBy=[[CAST(number.c0 AS Int64) + 
Int64(1)Int64(1)CAST(number.c0 AS Int64)number.c0 AS number.c0 + Int64(1)]], 
aggr=[[COUNT(CAST(number.c0 AS Int64) + Int64(1)Int64(1)CAST(number.c0 AS 
Int64)number.c0 AS number.c0 + Int64(1))]] |
   |               |   Projection: CAST(number.c0 AS Int64) + Int64(1) AS 
CAST(number.c0 AS Int64) + Int64(1)Int64(1)CAST(number.c0 AS Int64)number.c0    
                                                                                
                             |
   |               |     TableScan: number projection=[c0]                      
                                                                                
                                                                                
                       |
   | physical_plan | AggregateExec: mode=FinalPartitioned, gby=[number.c0 + 
Int64(1)@0 as number.c0 + Int64(1)], aggr=[COUNT(number.c0 + Int64(1))]         
                                                                                
                           |
   |               |   CoalesceBatchesExec: target_batch_size=8192              
                                                                                
                                                                                
                       |
   |               |     RepartitionExec: partitioning=Hash([number.c0 + 
Int64(1)@0], 8), input_partitions=1                                             
                                                                                
                              |
   |               |       AggregateExec: mode=Partial, gby=[CAST(number.c0 AS 
Int64) + Int64(1)Int64(1)CAST(number.c0 AS Int64)number.c0@0 as number.c0 + 
Int64(1)], aggr=[COUNT(number.c0 + Int64(1))]                                   
                            |
   |               |         ProjectionExec: expr=[CAST(c0@0 AS Int64) + 1 as 
CAST(number.c0 AS Int64) + Int64(1)Int64(1)CAST(number.c0 AS Int64)number.c0]   
                                                                                
                         |
   |               |           MemoryExec: partitions=1, partition_sizes=[1]    
                                                                                
                                                                                
                       |
   |               |                                                            
                                                                                
                                                                                
                       |
   
+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   2 row(s) fetched.
   Elapsed 0.015 seconds.
   ```
   
   ```shell
   ProjectionExec: expr=[CAST(c0@0 AS Int64) + 1 as CAST(number.c0 AS Int64) + 
Int64(1)Int64(1)CAST(number.c0 AS Int64)number.c0]                              
                                                                              |
   ```
   The `expr` of `ProjectionExec` is confusing. 
   
   The related code:
   
https://github.com/apache/datafusion/blob/b41ef20c5dad7bdd674e3cc5f35a9c99efae676c/datafusion/optimizer/src/common_subexpr_eliminate.rs#L676-L687
   
   Maybe we should make it more human-readable.
   
   ### Describe the solution you'd like
   
   ```shell
   ProjectionExec: expr=[CAST(c0@0 AS Int64) + 1 as CAST(number.c0 AS Int64) + 
Int64(1)]                                                                       
                                     
   ```
   or
   ```shell
   ProjectionExec: expr=[CAST(c0@0 AS Int64) + 1 as CAST(number.c0 AS Int64) + 
Int64(1)]<$SUB_IDEN...>                                                         
                                      
   ```
   
   ### Describe alternatives you've considered
   
   _No response_
   
   ### Additional context
   
   _No response_


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