Conversation
A correlated filter pulled through a SubqueryAlias kept the inner table qualifier. When that alias differed from the table name, the join condition named a column the rewritten subquery no longer had. Fixes apache#25837 Assisted by Cursor (Grok).
kumarUjjawal
self-requested a review
October 5, 2026 06:59
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
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.sltcover a correlated LATERAL filter through a derived-table alias that differs from the table name. They fail onmainand pass with this change. Existing optimizer tests pass, andcargo fmtandcargo clippyare 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.