-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[CALCITE-7279] Resolve ClickHouse identifier resolution error by aliasing nested JOIN projections #4692
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
core/src/main/java/org/apache/calcite/sql/dialect/ClickHouseSqlDialect.java
Show resolved
Hide resolved
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
Show resolved
Hide resolved
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java
Outdated
Show resolved
Hide resolved
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
Outdated
Show resolved
Hide resolved
|
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. |
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
Outdated
Show resolved
Hide resolved
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
Outdated
Show resolved
Hide resolved
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java
Outdated
Show resolved
Hide resolved
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java
Show resolved
Hide resolved
core/src/main/java/org/apache/calcite/sql/dialect/ClickHouseSqlDialect.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/calcite/sql/dialect/ClickHouseSqlDialect.java
Outdated
Show resolved
Hide resolved
mihaibudiu
left a comment
There was a problem hiding this 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
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java
Outdated
Show resolved
Hide resolved
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
Outdated
Show resolved
Hide resolved
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java
Outdated
Show resolved
Hide resolved
mihaibudiu
left a comment
There was a problem hiding this 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.
|
The CI failures seem transient, maybe they will go away if you add a new commit. |
a84b411 to
33cd482
Compare
186e59a to
2c84e5d
Compare
|
A bit early to squash commits, you should do that after the PR is accepted. |
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java
Show resolved
Hide resolved
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java
Outdated
Show resolved
Hide resolved
|
mihaibudiu
left a comment
There was a problem hiding this 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.
|
But, of course, now commits can be squashed |
…cit column aliases
|
Thanks everyone. |
|
xuzifu666
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM



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.