silundong opened a new pull request, #4898: URL: https://github.com/apache/calcite/pull/4898
## Jira Link [CALCITE-7482](https://issues.apache.org/jira/browse/CALCITE-7482) ## Changes Proposed 1. When rewriting a subquery in the ON clause (`SubQueryRemoveRule.matchJoin`), after collecting the `CorrelationId` used in the subquery, `CorrelationId` that do not belong to the current scope are excluded. 2. During initial plan generation, a lateral join is transformed into a `Correlate`. If at this point the right side contains a subquery that references variables from the left side (i.e., in the form of a nested correlated subquery), `TopDownGeneralDecorrelator` cannot be applied directly. This is because the subquery has not yet been fully removed — performing decorrelation prematurely would cause the free variables in the nested correlated subquery to be unable to locate their corresponding `Correlate` in subsequent processing. Like the initial plan below: ``` LogicalProject(ID=[$0], SAL=[$1], ID0=[$2], SAL0=[$3]) LogicalCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{0}]) LogicalValues(tuples=[[{ 1, 10 }, { 2, 20 }, { 3, 30 }]]) LogicalProject(ID=[$0], SAL=[$1]) LogicalJoin(condition=[EXISTS({ LogicalFilter(condition=[AND(=($0, $cor0.ID), =($1, $cor1.SAL))]) <- still have a free variable from $cor0 LogicalValues(tuples=[[{ 2, 200 }, { 5, 50 }]]) })], joinType=[inner], variablesSet=[[$cor1]]) LogicalValues(tuples=[[{ 2, 20 }, { 2, 200 }, { 3, 30 }]]) LogicalValues(tuples=[[{ 3, 30 }, { 4, 40 }]]) ``` -- 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]
