DeviousCardi opened a new pull request, #26350:
URL: https://github.com/apache/datafusion/pull/26350

   ## Which issue does this PR close?
   
   Closes #26221.
   
   ## Rationale for this change
   
   `sum(x)` and `sum(CAST(x AS FLOAT))` get the same schema name, so using both 
in one query fails even with separate aliases. The collision happens in the 
aggregate node before the projection applies those aliases.
   
   ## What changes are included in this PR?
   
   Use the display name for colliding aggregates when it differs from their 
schema name. Expression rebasing then resolves the original expression to the 
renamed aggregate column.
   
   This keeps the naming change local to SQL aggregation. Queries without 
distinct output aliases still get the existing duplicate projection name error.
   
   ## What is the testing strategy for this PR?
   
   SQLLogicTest cases cover both argument orders, multiple casts, `TRY_CAST`, 
`COUNT`, grouping, `HAVING`, and `ORDER BY`. The existing `approx_distinct` 
regression now checks successful execution, and an `EXPLAIN` case checks the 
aggregate names.
   
   ## Are there any user-facing changes?
   
   Queries that aggregate a column and a cast of it can now plan successfully 
when their output names are distinct.
   
   AI assistance: Claude Code generated the patch and tests; Codex read the 
diff and prepared this description. The scope assumes the fix belongs in SQL 
aggregate naming rather than changing cast schema names globally.
   


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to