Fix inconsistent AST formatting for GROUP BY CUBE(...) WITH ROLLUP#100376
Open
alexey-milovidov wants to merge 8 commits intomasterfrom
Open
Fix inconsistent AST formatting for GROUP BY CUBE(...) WITH ROLLUP#100376alexey-milovidov wants to merge 8 commits intomasterfrom
alexey-milovidov wants to merge 8 commits intomasterfrom
Conversation
`GROUP BY CUBE(x) WITH ROLLUP` was parsed into an AST with both `group_by_with_cube` and `group_by_with_rollup` flags set. The formatter then produced `GROUP BY x WITH ROLLUP WITH CUBE`, but the parser could not parse this back because the second `WITH` clause only accepted `TOTALS`. This caused a "Inconsistent AST formatting" exception in debug builds. Fix by replacing the two separate `WITH` parser blocks with a single loop that accepts any combination of `WITH ROLLUP`, `WITH CUBE`, and `WITH TOTALS` modifiers (rejecting duplicates). Fixes #100320 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
|
Workflow [PR], commit [83fe17a] Summary: ❌
AI ReviewSummaryThis PR fixes a real parser/formatter round-trip inconsistency for ClickHouse Rules
Final VerdictStatus: ✅ Approve |
…ests Syntax errors are caught by the client-side parser before being sent to the server, so they must use `clientError` instead of `serverError`. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 task
Member
Author
…ith-rollup-ast-formatting
…ith-rollup-ast-formatting
alexey-milovidov
added a commit
that referenced
this pull request
Mar 29, 2026
The test checked specific part names after `OPTIMIZE`, but with randomized settings (e.g. `enable_parallel_replicas`), the merge selector can pick different pairs of parts to merge, resulting in different part names. Check the count of active parts instead, which is always 2 regardless of merge order. Seen in #100376 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
alexey-milovidov
added a commit
that referenced
this pull request
Mar 29, 2026
The test checked specific part names after `OPTIMIZE`, but with randomized settings the merge selector can pick different pairs of parts to merge, resulting in different part names. Check the count of active parts instead, which is always 2 regardless of merge order. Seen in #100376 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ith-rollup-ast-formatting
Contributor
LLVM Coverage Report
Changed lines: 88.89% (24/27) · Uncovered code |
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.
GROUP BY CUBE(x) WITH ROLLUPwas parsed into an AST with bothgroup_by_with_cubeandgroup_by_with_rollupflags set. The formatter then producedGROUP BY x WITH ROLLUP WITH CUBE, but the parser could not parse this back because the secondWITHclause only acceptedTOTALS. This caused an "Inconsistent AST formatting" exception in debug builds.Fix by replacing the two separate
WITHparser blocks inParserSelectQuerywith a single loop that accepts any combination ofWITH ROLLUP,WITH CUBE, andWITH TOTALSmodifiers (rejecting duplicates).Fixes #100320
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix "Inconsistent AST formatting" exception in debug builds when using
GROUP BY CUBE(...) WITH ROLLUPor similar combinations.Documentation entry for user-facing changes