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

   ## Which issue does this PR close?
   
   - Closes #26234.
   
   ## Rationale for this change
   
   See issue #26234.
   
   ## What changes are included in this PR?
   
   When a correlated subquery refers to the outer query from two of its 
relations through columns with the same name, `SubqueryAlias` gives those 
columns unique aliases (`k`, `k:1`), but `replace_qualified_name` rewrote the 
pulled-up join filter by column name only, so both columns referred to the 
first one and the query returned wrong results. This affected EXISTS, NOT 
EXISTS, IN and scalar subqueries.
   
   Map each correlated column to the name it has in the alias's schema, found 
by its position in the decorrelated subquery's schema. Columns the schema only 
has under a derived table's alias keep the name-based mapping.
   
   ## What is the testing strategy for this PR?
   
   Introducing new tests for the affected subqueries.
   
   ## Are there any user-facing changes?
   
   Correcting the behaviour of queries that previously produced the wrong 
results.


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