MohamedAbdeen21 commented on issue #10280:
URL: https://github.com/apache/datafusion/issues/10280#issuecomment-2093703254

   Hey, this optimizer rule is used by so many test cases, so I wanted to 
collect opinions before proceeding with implementing the change.
   
   # My suggestion
   
   Using `let alias_symbol = format!("${{{curr_expr_id}}}");`  to mark common 
expressions. So the query above would be:
   
   ```sql
    AggregateExec: mode=Partial, gby=[${CAST(number.c0 AS Int64) + Int64(1)}@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)}] 
   ```
   
   # Some naming alternatives I've considered
   
   - Using `@0`, `@1`, etc ... However, the @ symbol is already used in the 
physical plan (check the query above), which means that you may have columns 
like `@0@0` which makes no sense.
   
   - `let alias_symbol = format!("{curr_expr_id}").replace(" ", "_");`. Sound 
like a good idea until you see it.
   
   ```sql
   AggregateExec: mode=Partial, gby=[CAST(number.c0_AS_Int64)_+_Int64(1)@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)
   ```
   
   It's not immediately obvious + what happens if the column doesn't have a 
space?
   
   Please feel free to share other alternatives.


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