Skip to content

[CALCITE-7646] CorrelateProjectExtractor does not handle nested field accesses cor0.field0.field1#5086

Open
mihaibudiu wants to merge 1 commit into
apache:mainfrom
mihaibudiu:issue7646
Open

[CALCITE-7646] CorrelateProjectExtractor does not handle nested field accesses cor0.field0.field1#5086
mihaibudiu wants to merge 1 commit into
apache:mainfrom
mihaibudiu:issue7646

Conversation

@mihaibudiu

Copy link
Copy Markdown
Contributor

Jira Link

CALCITE-7646

Changes Proposed

These changes make the helper class slightly more capable, enabling more programs to be decorrelated.

@mihaibudiu

Copy link
Copy Markdown
Contributor Author

@zabetak according to git blame you wrote most of this code, so I took the liberty to request your review.

… accesses cor0.field0.field1

Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
@mihaibudiu

Copy link
Copy Markdown
Contributor Author

I think the CI failure is transient, the tests pass locally.

@xuzifu666

xuzifu666 commented Jul 7, 2026

Copy link
Copy Markdown
Member

I think the CI failure is transient, the tests pass locally.

There shouldn't be any problems. I re-trigger sonar CI to double-check.

@mihaibudiu

Copy link
Copy Markdown
Contributor Author

The fact that I requested a review from @zabetak should not deter anyone else from reviewing this PR. I think it's a genuine improvement which will help our decorrelator handle more queries.

@iwanttobepowerful

Copy link
Copy Markdown
Contributor

Would it also be possible to add a few SQL-based test cases to QuidemTest?

@mihaibudiu

Copy link
Copy Markdown
Contributor Author

Sure, I will do that, but the results should not change, just the nature of the plan

@xuzifu666 xuzifu666 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my view the overall implementation is ok and meets the objectives. Apart from suggesting the addition of QuidemTest, I have left two comments for your reference.

// Find the correlated expressions from the right side that can be moved to the left
Set<RexNode> callsWithCorrelationInRight =
findCorrelationDependentCalls(correlate.getCorrelationId(), right);
// Only direct field accesses on the correlation variable, such as

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These comments should be left-aligned.


/** Test case for <a href="https://issues.apache.org/jira/browse/CALCITE-7646">[CALCITE-7646]
* CorrelateProjectExtractor does not handle nested field accesses cor0.field0.field1</a>. */
@Test void testNestedCorrelationFieldAccessInFilter() {

@xuzifu666 xuzifu666 Jul 12, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new logic returns null from visitCall for neutral subexpressions. The Javadoc example CASE(IS NOT NULL($cor0.PATH), $cor0.PATH, ARRAY(NULL)) seems not covered by any test. can we add a test to verify that constant/dynamic-parameter operands do not wrongly disqualify the enclosing correlated call?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants