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

   ### Describe the bug
   
   When a list of expressions has two aliases with the same name but different 
relation (`TableReference`) the function 
[`validate_unique_names`](https://github.com/apache/datafusion/blob/7c07948358eac81c4b297fa2400cba3c9ca55dc2/datafusion/expr/src/logical_plan/builder.rs#L1486)
 does fail. This is for example different for referencing columns, where the 
relation is taken into account. This happens because currently the 
[`SchemaDisplay`](https://github.com/apache/datafusion/blob/7c07948358eac81c4b297fa2400cba3c9ca55dc2/datafusion/expr/src/expr.rs#L2241C1-L2242C1)
 does not take the relation into account in [the following match 
case](https://github.com/apache/datafusion/blob/7c07948358eac81c4b297fa2400cba3c9ca55dc2/datafusion/expr/src/expr.rs#L2284C1-L2285C1).
   
   ### To Reproduce
   
   1. Create two expressions with alias to the same column.
   2. Call `validate_unique_names`.
   
   ### Expected behavior
   
   Since both columns can be disambiguated using the relation, the call to 
[`validate_unique_names`](https://github.com/apache/datafusion/blob/7c07948358eac81c4b297fa2400cba3c9ca55dc2/datafusion/expr/src/logical_plan/builder.rs#L1486)
 shouldn't result in failure. Additionally a SchemaDisplay should include the 
relation name. 
   
   ### Additional context
   
   I encountered this problem when implementing materialised views, as the view 
might contain two input tables with the same columns. Since I re-alias the 
columns to the right tables after a query rewrite, I am encountering this 
issue. It worked well with the improved 
[`SchemaDisplay`](https://github.com/apache/datafusion/blob/7c07948358eac81c4b297fa2400cba3c9ca55dc2/datafusion/expr/src/expr.rs#L2241C1-L2242C1).


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