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

   ## Which issue does this PR close?
   
   - Closes #25837.
   
   ## Rationale for this change
   
   A LATERAL subquery whose correlated filter goes through a derived-table 
alias failed to plan. When the filter was pulled up through the 
`SubqueryAlias`, it kept the inner table's qualifier. If the alias differed 
from the table name, the resulting join condition referenced a column the 
rewritten subquery no longer exposed, so the query errored instead of returning 
rows.
   
   ## What changes are included in this PR?
   
   When decorrelation pulls a correlated filter up through a `SubqueryAlias`, 
the filter's column references are requalified to the alias, so the join 
condition matches the subquery's output schema.
   
   ## What is the testing strategy for this PR?
   
   New cases in `lateral_join.slt` cover a correlated LATERAL filter through a 
derived-table alias that differs from the table name. They fail on `main` and 
pass with this change. Existing optimizer tests pass, and `cargo fmt` and 
`cargo clippy` are clean.
   
   ## Are there any user-facing changes?
   
   Queries of this shape now plan and return results instead of erroring. No 
public API changes.
   
   This change was made with help from Cursor (Grok). I reviewed and tested it.


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