[CALCITE-7753] CorrelateProjectExtractor corrupts plans with nested Correlates that reuse the same correlation id - #5231
[CALCITE-7753] CorrelateProjectExtractor corrupts plans with nested Correlates that reuse the same correlation id#5231snuyanzin wants to merge 1 commit into
CorrelateProjectExtractor corrupts plans with nested Correlates that reuse the same correlation id#5231Conversation
… Correlates that reuse the same correlation id
| * <a href="https://issues.apache.org/jira/browse/CALCITE-7753">[CALCITE-7753] | ||
| * CorrelateProjectExtractor corrupts plans with nested Correlates that reuse | ||
| * the same correlation id</a>. */ | ||
| @Test void testNestedCorrelatesSharingCorrelationId() { |
There was a problem hiding this comment.
As mentioned in jira: it is not reproducible with pure SQL in Calcite
There was a problem hiding this comment.
Because the bug requires two nested Correlates that share the same correlation id, and pure SQL (in Calcite) never produces that shape: Calcite's SqlToRelConverter gives every correlated subquery scope its own id.
|
|
I left a comment related to this in Jira questioning whether this fix belongs in Calcite. |
| boolean rightRebindsCorrelationId = | ||
| rebindsCorrelationId(right, correlate.getCorrelationId()); |
There was a problem hiding this comment.
I am wondering if its possible to plug the fix in findCorrelationDependentCalls to avoid traversing again a potentially large sub plan? How about stopping traversal inside findCorrelationDependentCalls if we encounter a correlate with the same id?



Jira Link
CALCITE-7753
Changes Proposed
The change to fix
CorrelateProjectExtractorfor downstream projects