gaoxinge opened a new issue, #5174:
URL: https://github.com/apache/arrow-datafusion/issues/5174

   **Is your feature request related to a problem or challenge? Please describe 
what you are trying to do.**
   
   This problem origin from 
https://github.com/dask-contrib/dask-sql/issues/948, which can be minimally 
reproduced by 
   
   ```sql
   SELECT 10, cast(10 as tinyint)
   ```
   
   The sql above will cause the duplicate column name error. And this is 
because 
   
   - cast use the expr as column name
   
   
https://github.com/apache/arrow-datafusion/blob/224c682101949da57aebc36e92e5a881ef3040d4/datafusion/expr/src/expr.rs#L1203-L1210
   
   - same column name is not valid
   
   
https://github.com/apache/arrow-datafusion/blob/224c682101949da57aebc36e92e5a881ef3040d4/datafusion/expr/src/logical_plan/builder.rs#L925-L948
   
   **Describe the solution you'd like**
   
   There are two soluntions here:
   
   1. rename the column name of cast expression
   
   For example, mysql use the whole cast expression as column name, like 
`CAST(Int64(10) AS Int8)` instead of `Int64(10)`. In this way, the column name 
of cast expression will be more precise, and also this can bypass the duplicate 
column name error.
   
   2. remove the unique column name validation
   
   In mysql and sql server, query support same column name. So I think we can 
remove the unique column name validation to make same column name coexist.
   


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