Skip to content

[CALCITE-7899] SubQueryRemoveRule binds an outer query's correlation variable to the wrong input when a Project has several sub-queries - #5366

Merged
iwanttobepowerful merged 1 commit into
apache:mainfrom
iwanttobepowerful:CALCITE-7899
Oct 29, 2026

Conversation

@iwanttobepowerful

Copy link
Copy Markdown
Contributor

…variable to the wrong input when a Project has several sub-queries
int count = 0;
List<RexNode> projects = project.getProjects();
while (true) {
final RexSubQuery e = RexUtil.SubQueryFinder.find(projects);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the other PR attacking a similar problem #5356 uses a new visitor which finds the innermost subquery first.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The earlier PR #5356 bundled fixes for several issues together — I was essentially experimenting with a few possible fix approaches at the time. I have now cleaned that PR up.

@sonarqubecloud

Copy link
Copy Markdown

@iwanttobepowerful iwanttobepowerful added the LGTM-will-merge-soon Overall PR looks OK. Only minor things left. label Oct 29, 2026
@iwanttobepowerful
iwanttobepowerful merged commit cf01ee8 into apache:main Oct 29, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

LGTM-will-merge-soon Overall PR looks OK. Only minor things left.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants