xiedeyantu opened a new issue, #21232: URL: https://github.com/apache/datafusion/issues/21232
### Describe the bug In a subquery containing a JOIN operation, when the two joined tables share a column with the same name (such as age), the JOIN result set includes duplicate column names. If the outer query uses a simple `select age` to reference this duplicate column, the database system does not throw the expected "ambiguous column reference" error but instead allows the query to execute. ### To Reproduce Create two tables: ``` create table a(aid int, age int); create table b(bid int, age int); ``` Execute the following query: ``` select age from (SELECT * FROM a join b on a.aid = b.bid) as t; ``` Observe the outcome: The query executes without error. ### Expected behavior Since the subquery t contains two columns named age (one from table a and the other from table b), the reference to age in the outer SELECT clause becomes ambiguous. The database system should throw a clear error, such as "Column 'age' in field list is ambiguous" or "ERROR: column reference 'age' is ambiguous". ### Additional context If we determine that this needs to be fixed, I will attempt to resolve the issue. -- 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]
