lewiszlw opened a new issue, #18975:
URL: https://github.com/apache/datafusion/issues/18975

   ### Describe the bug
   
   Execute below sqls in datafusion-cli
   ```
   create table t (a int);
   select max(a) as a1, max(cast(a, bigint)) as a2 from t;
   ```
   will get error: `Schema error: Schema contains duplicate unqualified field 
name "max(t.a)"`. I tried in postgres and it won't fail.
   
   I've found root cause. it's due to aggregate plan output schema building 
https://github.com/apache/datafusion/blob/main/datafusion/expr/src/logical_plan/plan.rs#L3492.
 It will call SchemaDisplay code. 
https://github.com/apache/datafusion/blob/52583528087362384be737be37c7ef093e7aa847/datafusion/expr/src/expr.rs#L2799-L2802
 The schema name of cast expr is same with column expr. 
   
   ### To Reproduce
   
   _No response_
   
   ### Expected behavior
   
   _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: [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