Skip to content

Conversation

@Dwrite
Copy link

@Dwrite Dwrite commented Dec 17, 2025

ClickHouse does not support standard nested JOIN syntax and has strict scoping rules for identifiers in subqueries. When a JOIN's right side is another JOIN, it must be wrapped in a subquery.

This commit ensures that the ClickHouse dialect:

Wraps nested JOINs in a subquery to satisfy syntax requirements.

Generates explicit column aliases (e.g., AS col_name) for all projected columns within the subquery. This prevents "Unknown Identifier" errors by ensuring internal table qualifiers are flattened and resolvable by the outer query block.

Avoids redundant subquery nesting to maintain optimal SQL structure.

@xiedeyantu
Copy link
Member

xiedeyantu commented Dec 18, 2025

Tip: The commit message, Jira title and PR title should be consistent. I think the commit message title is fine. PR title may lose something.

@Dwrite Dwrite changed the title [CALCITE-7279] Add subquery wrappers for nested JOINs in ClickHouse d… [CALCITE-7279] Add subquery wrappers for nested JOINs in ClickHouse dialect Dec 19, 2025
@Dwrite Dwrite changed the title [CALCITE-7279] Add subquery wrappers for nested JOINs in ClickHouse dialect [CALCITE-7279] Resolve ClickHouse identifier resolution error by aliasing nested JOIN projections Dec 22, 2025
@Dwrite Dwrite requested a review from mihaibudiu December 22, 2025 15:12
Copy link
Contributor

@mihaibudiu mihaibudiu left a comment

Choose a reason for hiding this comment

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

I will look again when you have removed the spurious changes

Copy link
Contributor

@mihaibudiu mihaibudiu left a comment

Choose a reason for hiding this comment

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

This looks fine, but I still have a few comments that are unaddressed.

@mihaibudiu
Copy link
Contributor

The CI failures seem transient, maybe they will go away if you add a new commit.

@mihaibudiu mihaibudiu added the LGTM-will-merge-soon Overall PR looks OK. Only minor things left. label Jan 6, 2026
@Dwrite Dwrite force-pushed the calciate-7279 branch 3 times, most recently from a84b411 to 33cd482 Compare January 11, 2026 10:06
@Dwrite Dwrite requested a review from mihaibudiu January 11, 2026 15:03
@Dwrite Dwrite force-pushed the calciate-7279 branch 2 times, most recently from 186e59a to 2c84e5d Compare January 12, 2026 15:28
@mihaibudiu
Copy link
Contributor

A bit early to squash commits, you should do that after the PR is accepted.
Now we have to read the whole PR again.

@Dwrite
Copy link
Author

Dwrite commented Jan 13, 2026

A bit early to squash commits, you should do that after the PR is accepted.
Now we have to read the whole PR again.
oh.sorry

@Dwrite Dwrite requested a review from mihaibudiu January 13, 2026 14:51
Copy link
Contributor

@mihaibudiu mihaibudiu left a comment

Choose a reason for hiding this comment

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

Lots of people have commented, but if no one else has additional comments, I think this is ready to merge.

@mihaibudiu
Copy link
Contributor

But, of course, now commits can be squashed

@Dwrite
Copy link
Author

Dwrite commented Jan 14, 2026

Thanks everyone.

@sonarqubecloud
Copy link

Copy link
Member

@xuzifu666 xuzifu666 left a comment

Choose a reason for hiding this comment

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

LGTM

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.

6 participants