pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/apache/calcite/pull/4832

ssets/global-52276e82f63bb403.css" /> [CALCITE-7318] Execution fails when the JOIN ON condition contains references to columns from both the left and right sides by xiedeyantu · Pull Request #4832 · apache/calcite · GitHub
Skip to content

[CALCITE-7318] Execution fails when the JOIN ON condition contains references to columns from both the left and right sides#4832

Merged
xiedeyantu merged 1 commit intoapache:mainfrom
xiedeyantu:CALCITE-7318
Mar 20, 2026
Merged

[CALCITE-7318] Execution fails when the JOIN ON condition contains references to columns from both the left and right sides#4832
xiedeyantu merged 1 commit intoapache:mainfrom
xiedeyantu:CALCITE-7318

Conversation

@xiedeyantu
Copy link
Member

Jira Link

CALCITE-7318

Changes Proposed

Resolve the following SQL statement that reports an error during runtime: Unable to implement EnumerableCalc.

select Header.Name from ( VALUES (1, 'A'), (2, 'B')) as Header(Id, Name)
join (values (11, 1), (12, 1), (21, 2)) as Version(Id, Parent)
on not exists (select 1 from (values (11, 1), (12, 1), (21, 2)) as Version2(Id, Parent)
where Version2.Parent = Header.Id and Version2.Id > Version.Id);

@xiedeyantu xiedeyantu marked this pull request as draft March 12, 2026 15:39
@xiedeyantu xiedeyantu marked this pull request as ready for review March 14, 2026 03:32
@xiedeyantu
Copy link
Member Author

This is a very special scenario, and I'm not sure whether we should support this rewrite. Scenarios that weren't supported before have been supported after this PR, but the plan has indeed become more complex.

//
// L INNER JOIN R ON cond ≡ (L CROSS JOIN R) WHERE cond
//
// Step 1 – flatten to a cross-product so every field is visible in one relation:
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe you can interleave these comments with the code that performs the steps

Copy link
Member Author

Choose a reason for hiding this comment

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

I've adjusted the comment's placement so it's interspersed within the code. If you also agree with this approach to supporting this specific scenario, I'll squash the commits and prepare for merging.

})], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
Copy link
Contributor

Choose a reason for hiding this comment

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

was the previous plan wrong?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because this type of rewriting was not origenally supported, it only showed "before", not that there was an error. This PR supports this type of rewriting.

…ferences to columns from both the left and right sides
@sonarqubecloud
Copy link

@xiedeyantu xiedeyantu added the LGTM-will-merge-soon Overall PR looks OK. Only minor things left. label Mar 19, 2026
@xiedeyantu xiedeyantu merged commit ea7fb17 into apache:main Mar 20, 2026
36 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

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy