feat(clickhouse): support PARTITION BY after ORDER BY and ARRAY JOIN#2283
Open
cristhiank wants to merge 2 commits intoapache:mainfrom
Open
feat(clickhouse): support PARTITION BY after ORDER BY and ARRAY JOIN#2283cristhiank wants to merge 2 commits intoapache:mainfrom
cristhiank wants to merge 2 commits intoapache:mainfrom
Conversation
ClickHouse DDL allows PARTITION BY to appear after ORDER BY, which differs from standard SQL ordering. This change makes the parser accept both orderings when using the ClickHouseDialect or GenericDialect. Fixes a parse failure for production ClickHouse CREATE TABLE statements like: CREATE TABLE t (...) ENGINE = MergeTree() ORDER BY (...) PARTITION BY expr Co-authored-by: Copilot <[email protected]>
ClickHouse supports ARRAY JOIN clauses for unnesting arrays inline. This adds JoinOperator variants for ARRAY JOIN, LEFT ARRAY JOIN, and INNER ARRAY JOIN. These joins take a table expression (the array to unnest) rather than a standard table reference, and do not use ON/USING constraints. Also adds Spanned impls for the new variants in spans.rs. Co-authored-by: Copilot <[email protected]>
d27aeca to
097a929
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two ClickHouse dialect improvements:
PARTITION BY after ORDER BY — ClickHouse CREATE TABLE DDL places PARTITION BY after ORDER BY, which differs from standard SQL. The parser now accepts both orderings when using the ClickHouseDialect or GenericDialect.
ARRAY JOIN support — Adds \JoinOperator\ variants for \ARRAY JOIN, \LEFT ARRAY JOIN, and \INNER ARRAY JOIN. These are ClickHouse-specific constructs for unnesting arrays inline.
Motivation
These patterns appear in production ClickHouse deployments and currently fail to parse with the ClickHouseDialect.
Changes