Repository navigation
Conversation
`ParserViewTargets` accepts the clauses of the targets of a TimeSeries table in any order, and one target's clauses may be separated by a clause of another target. The `ASTViewTargets` setters appended each AST to `children` in that clause order, while the formatter writes the clauses of each target together, `INNER COLUMNS` before `INNER ENGINE`. A query written `RECENT SAMPLES INNER ENGINE = ... RECENT SAMPLES INNER COLUMNS (...)` therefore parsed to children `[engine, columns]` and its formatted text to `[columns, engine]`, and the debug check in `executeQueryImpl` aborted with `Inconsistent AST formatting` (STID 1941-1bfa). It killed `Stateless tests (amd_debug, parallel)` on ClickHouse#123144, whose new test uses that order. `clone()` and `readJSON()` rebuilt `children` in a third order (`inner_engine` first). `normalizeChildrenOrder()` rebuilds `children` from `targets` in the order `formatTarget` writes the clauses: per target the table AST, the inner columns, the inner engine. The three AST setters, `clone()` and `readJSON()` use it, so the parsed AST, its formatted and reparsed copy, its clone and its JSON round trip have the same children. Definitions already written in the formatted order keep exactly the children they had. This follows `ASTQueryWithOutput::output_option_members` and `ASTStorage::normalizeChildrenOrder`. The new stateless test creates the CI shape and compares `EXPLAIN AST` of ENGINE-first and interleaved definitions with the formatted order; the new gtest case checks clone and JSON round trip hashes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Pre-PR validation gate and internal review (click to expand)
Internal second-model review, 1 finding: |
|
cc @nikitamikhaylov @george-larionov, could you review this and add the |
|
Workflow [PR], commit [71deca6] Summary: ✅
AI ReviewSummaryReviewed #128897 at Final VerdictStatus: ✅ Approve. |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units190 translation units recompiled, 1503 s compile time in total, 190 of them have a recent master baseline. |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
The AST of a
TimeSeriestable definition no longer depends on the order in which theINNER COLUMNSandINNER ENGINEclauses of its targets are written, so debug builds no longer reportInconsistent AST formattingfor such a definition.Description
A debug server aborts with
Logical error: 'Inconsistent AST formatting'(STID 1941-1bfa) when aTimeSeriestarget'sINNER ENGINEclause comes before itsINNER COLUMNSclause, or when the clauses of one target are separated by a clause of another target. Both are valid syntax. It killedStateless tests (amd_debug, parallel)on #123144, whose new test writesRECENT SAMPLES INNER ENGINE = ... RECENT SAMPLES INNER COLUMNS (...): job report.Root cause: the
ASTViewTargetssetters append each AST tochildrenin the order the clauses are parsed, while the formatter writes the clauses of each target together,INNER COLUMNSbeforeINNER ENGINE. The formatted query parses back to a different child order, so its tree hash differs.clone()andreadJSON()used a third order.Change:
ASTViewTargets::normalizeChildrenOrder()rebuildschildrenfromtargetsin the order the formatter writes them (per target: table, inner columns, inner engine). The setters,clone()andreadJSON()use it, so the parsed AST, its formatted and reparsed copy, its clone and its JSON round trip have the same children. A definition already written in the formatted order (stored metadata,SHOW CREATE) keeps the same AST. Release builds do not run this check and created the table correctly.Validation: the new test
05493_time_series_target_clause_orderaborts an unfixed debug server and passes 50/50 with randomized settings on the fixed one. The new gtest caseTreeHashCompleteness.ViewTargetsCloneAndJSONRoundTripHashEqualfails without the change. TimeSeries, AST JSON and materialized view tests give the same results before and after.Workflow [PR]
Sync PR [sync-upstream/pr/128897]