[CALCITE-7505] RelToSqlConverter produces duplicate FROM aliases for correlated subqueries when hasImplicitTableAlias() is true#5036
Open
Dwrite wants to merge 1 commit into
Open
Conversation
…correlated subqueries when hasImplicitTableAlias() is true
|
mihaibudiu
reviewed
Jun 22, 2026
| /** Test case for | ||
| * <a href="https://issues.apache.org/jira/browse/CALCITE-7505">[CALCITE-7505] | ||
| * RelToSqlConverter produces duplicate FROM aliases for correlated subqueries</a>. */ | ||
| @Test void testExistsSubQueryAliasConflict() { |
Contributor
There was a problem hiding this comment.
why is this using hasImplicitTableAlias()?
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.



Jira Link
CALCITE-7505
This PR fixes incorrect SQL generation for correlated sub-queries in a
Filter'sWHEREclause whenSqlDialect#hasImplicitTableAlias()istrue.The issue was that
Filterdid not preserve correlation variables, soRelToSqlConvertercould not identify when the current node was the binding point of a correlation variable. As a result, required aliases could be omitted or duplicated, causing correlated references to resolve against the wrong scope.The fix adds
variablesSettoFilter/LogicalFilterand only applies correlation alias reset when the currentFilter/Projectactually binds the variable, the input row type matches, and the input is not aBiRel.A follow-up change will cover similar correlated cases in
Joinconditions.