Repository navigation
Fix inconsistent AST formatting for a no-argument window function in CODEC - #107806
Conversation
…CODEC A function with no arguments inside a `CODEC` (or engine) declaration is formatted without parentheses (e.g. `NONE`, `LZ4`, `MergeTree`), because the codec/engine parser sets `noEmptyArgs` on it (and `setNoEmptyArgs` even clears the empty arguments node). A no-argument *window* function parsed in that context — e.g. `CODEC(cume_dist() OVER (...))` — was stripped of its `()` too, but it must keep them: `cume_dist OVER (...)` re-parses as `cume_dist() OVER (...)`, so the formatting did not survive a parse round-trip and tripped the `Inconsistent AST formatting` logical error (found by the AST fuzzer, STID 1941-26fa). Always print a window function's parentheses in `ASTFunction` formatting. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Workflow [PR], commit [20d1edb] Summary: ✅
AI ReviewSummaryThis PR fixes Final VerdictStatus: ✅ Approve |
…t-window-in-codec
|
Continued via Re-merged Both prior CI failures are unrelated to this change, which only affects
@groeneai, the stress failure above is an unrelated, pre-existing fuzzer-found logical error — could you route/investigate it in a separate PR? The reproducer query is above and the CIDB link is in the CI report. |
|
@alexey-milovidov Confirmed: STID 2672-39ba is the #91119 family (correlated scalar subquery under Reproduced on master HEAD (debug, build id SET allow_experimental_correlated_subqueries = 1, group_by_use_nulls = 1;
SELECT number, number % 2, (SELECT sum(number))
FROM numbers(10) GROUP BY number % 2, number WITH CUBE
ORDER BY number, number % 2, sum(number);Exact match for the stress stack. Trigger isolated (both required, deterministic): drop Root cause: under Fix: #104350 ( |
…t-window-in-codec
|
Continued via Re-merged The three CI reds on the previous run are all unrelated master-wide flakes / infra, none of which touch
The re-merge triggers a fresh CI run, which should clear these transient flakes. AI Review is ✅ Approve, 0 unresolved review threads, changed-lines coverage 5/5 (100%). |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 5/5 (100.00%) | Lost baseline coverage: none · Uncovered code |
…-ast-window-in-codec Fix inconsistent AST formatting for a no-argument window function in CODEC
The AST fuzzer found an
Inconsistent AST formattinglogical error (STID 1941-26fa) on the stress test of #106522: a no-argument window function inside aCODECdeclaration loses its parentheses when formatted.A function with no arguments inside a
CODEC(or an engine) is intentionally formatted without parentheses —NONE,LZ4,MergeTree— because the codec/engine parser (ParserIdentifierWithOptionalParameters) callssetNoEmptyArgs(true), which also clears the empty arguments node. When the parsed element is a window function, e.g.CODEC(cume_dist() OVER (...)), its()was dropped too. But a window function must keep them:cume_dist OVER (...)re-parses ascume_dist() OVER (...), so the formatted query did not survive a parse round-trip, tripping the consistency check.The fix makes
ASTFunctionformatting always print a window function's parentheses (f() OVER (...)), regardless ofnoEmptyArgs. Plain zero-argument codecs and engines (NONE,LZ4,MergeTree) still format without parentheses.The fuzzer's
CREATE TABLEis itself degenerate (a window function is not a valid codec), but the formatter must still round-trip any query the parser accepts.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed an
Inconsistent AST formattinglogical error for a no-argument window function inside aCODECor engine declaration (e.g.CODEC(cume_dist() OVER (...))); such a function now keeps its parentheses so the query survives a format/parse round-trip.Documentation entry for user-facing changes
Version info
26.6.1.1178