Skip to content

Keep unread parameters out of the argMin/argMax/intervalLengthSum state type - #118156

Open
groeneai wants to merge 26 commits into
ClickHouse:masterfrom
groeneai:fix-argmin-state-type-parameters
Open

groeneai wants to merge 26 commits into
ClickHouse:masterfrom
groeneai:fix-argmin-state-type-parameters

Conversation

@groeneai

@groeneai groeneai commented Sep 4, 2026 •

Copy link
Copy Markdown
Collaborator

Closes: #118168
Related: #118006
Related: #110143

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

argMin, argMax and intervalLengthSum no longer put their unread parameters into the state they produce, neither into the state type nor into the name a serialized state carries, so a Map parameter no longer creates a table that cannot load or a state that cannot be inserted back. This also covers such a state behind a combinator (argMinIfState(map(1, 2))(...)) or behind the adapter for Nullable arguments, which is a bug of released versions.

Description

argMinState(map(1, 2))(...), and the same call on argMax, its aliases and intervalLengthSum, produced AggregateFunction(argMin([(1, 2)]), UInt64, UInt64). On 26.9 a table built from such a state is accepted and queryable, then fails to load on ATTACH and at server start. The same name breaks two more user-reachable paths. Since #121725 such names parse, so master no longer fails on these, bare or wrapped; there this PR only drops the unread parameter from the state type and the state name.

The two other carriers
CREATE TABLE t (s AggregateFunction(argMin, UInt8, UInt8)) ENGINE = Memory;
INSERT INTO t VALUES (arrayReduce('argMinState(map(1, 2))', [1, 2], [1, 2]));
-- Code: 43, cannot insert field with type AggregateFunction(argMin([(1, 2)]), UInt8, UInt8)
SELECT dynamicType(x) FROM VALUES('x Dynamic', (arrayReduce('argMinState(map(1, 2))', [1, 2], [1, 2])));
-- Code: 36, Expected a literal or a CAST of a literal, got '[(1, 2)]'

Root cause: #110143 forwards the caller's parameters to the base class in both constructors, and a Map renders as [(1, 2)], which parseFieldFromCastedLiteral rejected before #121725. That name is built twice - once for the type, once for the column that stamps it into every state serialized into a Field - so both spellings had to change.

Neither function reads a parameter, so getStateParameters names what a state depends on - nothing here - and both spellings follow it. getParameters is untouched, so the equality AggregateFunctionArray asserts, which #110143 exists for, keeps holding.

Combinator- and adapter-wrapped states (-If, -OrNull, -Distinct, -ForEach, -Array, the null adapter for a Nullable argument) had the same defect for another reason: each is constructed with the caller's parameters, so it carried the Map even where the function it wraps does not. That leg fails on a pre-#110143 build too (reported in #118168) and is fixed here: a wrapper answers for the function it wraps. -Resample and -Tuple do not pass the caller's list on unchanged: -Resample keeps its trailing (begin, end, step), -Tuple follows the elements that have a state. A tuple of only-null elements keeps them: every element is then the placeholder that deliberately carries them.


Workflow [PR]
Sync PR [sync-upstream/pr/118156]

…m` state type

`argMinState(map(1, 2))(...)`, and the same call on `argMax`, on the aliases
`argAndMin`, `argAndMax`, `min_by`, `max_by`, and on `intervalLengthSum`,
produced a state type printed as
`AggregateFunction(argMin([(1, 2)]), UInt64, UInt64)`. A table created from
such a state is accepted and queryable, and its own metadata then fails to
parse, so the table does not load on `ATTACH` or at server start and recovery
needs hand-editing the metadata `.sql`.

Root cause: ClickHouse#110143 changed both constructors to forward the caller's
parameters to the base class, which it must do because `AggregateFunctionArray`
throws `LOGICAL_ERROR` when `parameters != nested_func->getParameters()`.
`IAggregateFunction::getStateType` then puts those parameters into
`DataTypeAggregateFunction`, whose name renders each one with
`FieldVisitorToString`, under which a `Map` becomes `[(1, 2)]`. On reload
`parseFieldFromCastedLiteral` accepts only an `ASTLiteral` or a two-argument
`CAST` of a literal, so that spelling is rejected with `Code: 36`. Both classes
already dropped the parameters in `getNormalizedStateType`; `getStateType` was
never given the same treatment, and that inconsistency is the defect.

Neither function ever reads a parameter, so `getStateType` is overridden in
both classes to build the state type with an empty parameter list, mirroring
each class's existing `getNormalizedStateType`. `getParameters` is untouched,
so the wrapper-vs-nested parameter equality that `AggregateFunctionArray`
asserts, and that ClickHouse#110143 exists for, keeps holding. The printed state type
returns to exactly what master printed before ClickHouse#110143, a name the parser
already accepts.

Test 04368 pinned the two parameterized state-type names that this changes, so
its reference is updated and three comments that became false are corrected.
New test 05076 covers the printed state type for both families and a
`DETACH`/`ATTACH` reload.

Combinator- and adapter-wrapped state types (`-If`, `-OrNull`, `-Distinct`,
`-ForEach`, `-Array`, and the implicit null adapter used when an argument is
`Nullable`) build their state type from the wrapper's own parameters and still
carry the `Map`. That is unchanged here: it is measured byte-identical on a
pre-ClickHouse#110143 build, so it is not this regression, and it is not fixable by
propagating through `getNestedFunction` because `AggregateFunctionResample`'s
own parameters determine its state size.

Related: ClickHouse#118006

Co-Authored-By: Claude Opus 5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-review-bot PR origin: review-bot finding on a groeneai PR labels Sep 4, 2026
@groeneai

groeneai commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review

An independent cold review and a second-model gate ran against this diff over two rounds before it
was opened. Two findings were declined with evidence; neither needed a source change.

❌ "The state-type policy is bypassed for WithMergeableState, so parameterized queries still
publish an unparsable header."
The intermediate header's parameters come from the query's own
parameter nodes, not from getStateType (ExpressionAnalyzer.cpp:607 for the old analyzer,
PlannerAggregation.cpp:28 for the new one), so #110143 never changed them and this change touches
neither file. Pre-existing master behaviour, now named in the description with the other two.

⚠️ "Use Closes: rather than Related: for the linked issue." The issue is not mine to close;
its disposition stays with its author.

An earlier round raised the column-vs-type name divergence: it was measured on pre-fix and post-fix
builds rather than argued, and the outcome is in the description.

@clickhouse-gh clickhouse-gh Bot closed this Sep 4, 2026
@clickhouse-gh clickhouse-gh Bot reopened this Sep 4, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [0d5173b]

Summary: ✅


AI Review

Summary

Reviewed #118156 at 0d5173b33b25cc34ebd68b89c775f88e0cd1dd39, including the current diff and every prior discussion thread. The change excludes unread parameters from aggregate state identities while preserving constructor parameters and the parameters owned by Resample. No actionable findings remain; the current parser also accepts the Map spelling underlying the earlier only-null finding.

State-name consumers traced: metadata parsing and binary type decoding preserve legacy declarations; ColumnAggregateFunction insertion and convertFieldToType use shared state matching; Dynamic and Variant infer or accept the resulting state type; -Merge compares normalized state representations. The focused 04368, 05076, 05180, and only-null 04057 regression tests pass in the head's Fast test report. No local build or tests were run.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Sep 4, 2026
@groeneai

groeneai commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator Author

cc @Algunenano @rschu1ze, could you review this? argMin, argMax and intervalLengthSum never read their parameters, but #110143 began forwarding them to the base class, so getStateType put them into the state type where a Map renders as [(1, 2)] and the type parser then rejects the table's own metadata on reload. The fix overrides getStateType in both classes to use an empty parameter list, mirroring their existing getNormalizedStateType, and leaves getParameters untouched so the -Array invariant that #110143 exists for keeps holding.

@clickhouse-gh clickhouse-gh Bot added the comp-aggregate-functions Aggregate function implementations (sum, avg, count, quantile, combinators, etc.). label Sep 4, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 0d5173b33 with master ed426a200 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

⚠️ Significant changes: object file sizes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes ⚠️

149 object files changed (+412.11 KiB total), 0 added.

Object file Master PR Δ
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionsArgMinArgMax… 17.38 MiB 16.80 MiB -596.93 KiB (-3.35%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionUniq.cpp.o 14.67 MiB 14.73 MiB +62.86 KiB (+0.42%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionCovar.cpp.o 7.52 MiB 7.56 MiB +47.23 KiB (+0.61%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionCorr.cpp.o 7.73 MiB 7.78 MiB +46.94 KiB (+0.59%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionGroupArrayMov… 6.38 MiB 6.42 MiB +42.29 KiB (+0.65%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionGroupNumericI… 6.09 MiB 6.12 MiB +31.64 KiB (+0.51%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionSum.cpp.o 4.28 MiB 4.31 MiB +29.25 KiB (+0.67%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionIntervalLengt… 1.01 MiB 1008.43 KiB -28.23 KiB (-2.72%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionUniqCombined1… 3.51 MiB 3.54 MiB +24.36 KiB (+0.68%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionUniqCombined1… 3.51 MiB 3.54 MiB +24.36 KiB (+0.68%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionUniqCombined1… 3.51 MiB 3.54 MiB +24.36 KiB (+0.68%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionUniqCombined1… 3.51 MiB 3.54 MiB +24.35 KiB (+0.68%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionUniqCombined1… 3.51 MiB 3.54 MiB +24.35 KiB (+0.68%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionUniqCombined1… 3.51 MiB 3.54 MiB +24.35 KiB (+0.68%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionUniqCombined1… 3.52 MiB 3.54 MiB +24.35 KiB (+0.68%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionUniqCombined2… 3.51 MiB 3.54 MiB +24.35 KiB (+0.68%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionUniqCombined1… 3.51 MiB 3.54 MiB +24.35 KiB (+0.68%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionAvgWeighted.c… 14.82 MiB 14.85 MiB +22.33 KiB (+0.15%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionQuantileExact… 3.45 MiB 3.47 MiB +20.39 KiB (+0.58%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/Combinators/AggregateFunctionR… 265.18 KiB 284.83 KiB +19.66 KiB (+7.41%)

711 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Slowest function optimization changes (ThinLTO)

Median per-function time ratio to the master baseline: programs/clickhouse ×0.78 (each binary is linked separately, on a different machine and with different build flags); deltas below are relative to it.

Binary Function Master PR Δ vs median
programs/clickhouse DB::registerFunctionConversion(DB::FunctionFactory&) 7.3 s 15.2 s +9.4 s (+165%)
Compile time of recompiled translation units

336 translation units recompiled, 3304 s compile time in total, 336 of them have a recent master baseline.

Job report

@zlareb1

zlareb1 commented Sep 4, 2026

Copy link
Copy Markdown
Member

The combinator- and Nullable-adapter-wrapped shapes this PR's description measures as pre-existing now have a tracker: #118168 (reproduced on 26.8.2.7 and on this PR's head build — the unwrapped calls reattach fine there, the -If and Nullable-adapter legs still brick on ATTACH and at server start). Filed separately since it is not a #110143 regression and affects released versions.

@groeneai

groeneai commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks, that is the right split. I added Related: https://github.com/ClickHouse/ClickHouse/issues/118168 to the description, so the shapes it measures as pre-existing now point at your tracker.

Two in-tree constraints, since the issue offers rejecting the ignored parameters as one of the two ways out. #110143's own test records why they are accepted rather than rejected: hard-rejecting them would make legacy AggregateFunction(intervalLengthSum(...)) metadata unreadable on upgrade (tests/queries/0_stateless/04368_group_array_moving_array_combinator_parameter.sql). And the type-side route has to leave getParameters alone: the AggregateFunctionArray constructor throws LOGICAL_ERROR when its own parameters differ from the nested function's, which is the invariant #110143 exists for.

`argMin`, `argMax` and `intervalLengthSum` accept parameters but never read them. ClickHouse#110143 started
preserving them in `getParameters()` (the -Array combinator requires the wrapper's parameters to
equal the nested function's), and this PR kept them out of the state type. The name that travels
with a state serialized into a `Field` is built separately, in
`ColumnAggregateFunction::getTypeString()`, straight from `getParameters()`, so it still spelled
them out and disagreed with the state type:

    CREATE TABLE t (s AggregateFunction(argMin, UInt8, UInt8)) ENGINE = Memory;
    INSERT INTO t VALUES (arrayReduce('argMinState(map(1, 2))', [1, 2], [1, 2]));
    -- Code: 43, Cannot insert field with type AggregateFunction(argMin([(1, 2)]), UInt8, UInt8)
    --           into column with type AggregateFunction(argMin, UInt8, UInt8)

    SELECT dynamicType(x) FROM VALUES('x Dynamic', (arrayReduce('argMinState(map(1, 2))', [1, 2], [1, 2])));
    -- Code: 36, Expected a literal or a CAST of a literal, got '[(1, 2)]'

A `Map` parameter renders as `[(1, 2)]`, which the `AggregateFunction` type parser rejects, so
every consumer that re-derives a type from that name fails: `ColumnAggregateFunction::insert`,
`convertFieldToType`, and `FieldToDataType` when `Dynamic`/`Variant` discovers the variant type.

State a single property instead of duplicating the parameter list: `areParametersPartOfState()`
replaces the two per-function `getStateType()`/`getNormalizedStateType()` overrides and also
decides what the column prints, so both carriers agree by construction. `getParameters()` keeps
returning the real parameters, so the -Array invariant is untouched.

Combinator-wrapped shapes (`argMinIfState`, `argMinArrayState`, ...) build their state type from
the wrapper's own parameters, fail the same way on master, and are unchanged here; they are
tracked in ClickHouse#118168.

A name that still spells those parameters (declared metadata, a binary encoded type, an older
server) denotes the same state, and `nameMatchesState` cannot recognise it because it starts by
parsing the name, so `acceptsStateTypeName` compares that spelling verbatim as well.
Comment thread src/Columns/ColumnAggregateFunction.cpp Resolved
groeneai and others added 6 commits September 8, 2026 10:42
`ColumnAggregateFunction::insert`/`tryInsert` and `convertFieldToType` both answer the same
question - does the state name carried by a `Field` denote this function's state - and each had
its own answer. The column additionally accepted a name that still spells parameters the
function never reads, `convertFieldToType` accepted an exact name or `nameMatchesState` only,
so the two rules could drift apart.

Move that tolerance into `nameMatchesState`, which both call. The spelling compared verbatim is
now the one `DataTypeAggregateFunction` renders rather than the column's own, which matters
because the only producer of such a name is a type whose parameters the factory kept (a type
decoded from the binary encoding), and that type renders its name through
`shouldPrintParametersWithTypes`.

Measured on every reachable shape (a `Dynamic` MergeTree part written by a build that carries
the regression and read back, a state Field converted to its state type, `VALUES`, `IN`, `CAST`,
merge): identical results before and after, so this is a consolidation, not a behaviour change.
The rule accepts a state name that spells parameters the function never reads, which is how a
`Field` taken from a type decoded with those parameters still matches the state type that drops
them. No SQL construct produces such a name (a `Map`-parameterized `AggregateFunction` type
cannot be declared, and the column stamps the parameterless spelling into every `Field`), so a
unit test is the only way to pin it. Verified live: with the verbatim comparison in
`nameMatchesState` removed, the test fails on `tryInsert`.

Both carriers are asserted, `ColumnAggregateFunction::tryInsert` and `convertFieldToType`, plus a
negative control naming a different function's state.
`.claude/CLAUDE.md` asks for literal class and function names inside inline code blocks, and for a
function to be named `f` rather than `f()`.
The mechanism it narrated is in the commit that added the test.
…type

A combinator and the adapter for `Nullable` arguments are constructed
with the caller's parameters, so `argMinIfState(map(1, 2))(a, b, cond)`
and `argMinState(map(1, 2))(toNullable(a), b)` kept writing
`AggregateFunction(argMinIf([(1, 2)]), ...)` into the table metadata -
a type the parser rejects, so the table could not be attached and did
not load after a restart, while the bare call was already clean.

The wrappers now answer for the function they wrap, as they do for
`shouldPrintParametersWithTypes`. `-Resample`, the one combinator that
takes parameters of its own, answers for those itself.

Closes: ClickHouse#118168
@clickhouse-gh

clickhouse-gh Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

🟢 AI verdict: improvement — 1 query(s) improved out of 31 analysed

This PR changes which parameters appear in aggregate function state type names: argMin, argMax and intervalLengthSum now leave out parameters they never read, and combinators follow the function they wrap. It does not change how aggregation itself runs, and no ClickBench or TPC-H query builds or names -State types. ClickBench Q20 shows a large, consistent -43.6% with CPU time roughly halved, so its verdict stands under the hard trust rule, but this diff gives no explanation for it. Check the baseline build or rerun before crediting this PR. Q33 and Q34 (about -7%) fall inside master's normal variance band and correctly show no change, and Q28 is borderline. None of the three can be linked to this diff.

clickbench

🟢 1 improved · ⚠️ 1 inconclusive

Flagged queries (2 of 43)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
🟢 20 improvement 220 124 -43.6% <0.0001 Large, consistent shift (-43.6%) with CPU time roughly halved. The diff only changes how aggregate state types are named, which this query does not use, so the cause still needs to be found.
⚠️ 28 not_sure 1058 999 -5.6% 0.0095 Borderline -5.6% with mixed signals from the two tests and noisy measurements. Nothing in the diff touches this query's execution path.

Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on.

tpch_adapted_1_official

🟢 No significant changes

Debug info
  • StressHouse run: a2b90cb2-6507-4785-996d-6e671300d923
  • MIRAI run: 81342df1-dc33-4f2b-b5c4-1897211a0a54
  • PR check IDs:
    • clickbench_63632_1791932833
    • clickbench_63653_1791932832
    • clickbench_63895_1791932905
    • tpch_adapted_1_official_64336_1791932934
    • tpch_adapted_1_official_64357_1791932935
    • tpch_adapted_1_official_64598_1791932970

`-Resample` is constructed with the wrapped function's parameters followed by
its own `(begin, end, step)`, and `transformParameters` strips just the last
three before building the nested aggregate; `-Tuple` builds one nested function
per tuple element and answers for none of them. Both therefore kept a parameter
the wrapped function never reads: `argMinResampleState(map(1, 2), 0, 2, 1)(...)`
and `argMinTupleState(map(1, 2))(...)` announced
`AggregateFunction(argMinResample([(1, 2)], 0, 2, 1), ...)` and
`AggregateFunction(argMinTuple([(1, 2)]), ...)`, types the parser rejects, so a
table holding such a state could not be attached and did not load after a
restart - the shape the bare call and the other wrappers no longer write.

A boolean cannot express which parameters those are, so the property is now the
set itself: all of them by default, none for a function that ignores them, for
`-Resample` its own three plus whatever the wrapped function answers for, and
for `-Tuple` the answer of an element that has a state. Both carriers of a state
name read the same set, and `begin`, `end` and `step` still belong to it, so
states over different resample ranges keep different types.

A tuple whose every element is only-null keeps its parameters as before: each
element is then the placeholder that deliberately carries the caller's list, as
`04057_aggregate_function_nothing_with_parameters` pins, and no element is left
to say that the parameters go unread.
@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Sep 10, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member

@groeneai, fix conflicts.

Two conflicts, both in the state-name printer this branch shares with ClickHouse#119810
(merged as d9c814e), which took the DataTypeAggregateFunction::formatParameters
helper out of this branch:

- src/Columns/ColumnAggregateFunction.cpp: master now calls the shared helper with
  getParameters(). This branch exists to print getStateParameters() there instead, so
  the argument is kept and the rest of master's hunk (the SipHashingWriteBuffer change
  to updateHashWithValue) is taken as is.

- src/Columns/tests/gtest_column_aggregate_function.cpp: both sides appended a test at
  the end of the file. Both are kept; they cover different printers, quantile with a
  Decimal level from master and an argMin state name carrying a Map parameter here.

Nothing else conflicted: the formatParameters consolidation and its comments are
already on master in identical form, so the merge drops this branch's copy of them and
keeps only the getStateParameters mechanism plus the parameter-tolerant nameMatchesState.

Co-Authored-By: Claude Opus 5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

Conflicts resolved in 750e956 (merge of master, no force-push).

Both were in the state-name printer this branch shares with #119810, which took DataTypeAggregateFunction::formatParameters out of here when it merged, so this was a semantic conflict rather than a textual one:

  • ColumnAggregateFunction.cpp: master calls the shared helper with getParameters(); this PR exists to pass getStateParameters() there, so that argument is kept and the rest of master's hunk (SipHashingWriteBuffer in updateHashWithValue) is taken as is.
  • gtest_column_aggregate_function.cpp: both sides appended a test at the end of the file, covering different printers, so both are kept.

The merge drops this branch's now-redundant copy of formatParameters and keeps only the getStateParameters mechanism. Checked on the merged head: ColumnAggregateFunction.* gtests 3/3, 04368/05076/05180 pass, and reverting just that one-line argument reddens 05076.

Picks up the revert of the 05147 granule assertions (ClickHouse#121135), which broke
Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel)
on master and on every PR whose merge ref predated it.
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 750e956

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel) / 05147_ngrambf_like_escaped_backslash_run Not from this PR. Trunk-wide: the two trimLeft(explain) granule assertions added by #118279 do not strip the box-drawing prefix │ that a sibling read step introduces under parallel replicas, so the run printed │ Granules: 1/3. 16 true-master hits plus 22 other PRs on 2026-09-20, the granule counts themselves correct #121135 (external, merged 2026-09-20 04:10Z) removed the assertions from master. The tree that ran still carried them, while this PR's own head does not, so I merged master @ 07c65e656cd560740b3f3494fef5d679789db88b to pin a base that has the revert. #121136 (external, open) re-lands the test with the assertion fixed
Build profile diff Not from this PR. The job's own read of the CI logs cluster raises RuntimeError: CI logs cluster query failed at ci/jobs/build_profile_diff_job.py:234, so no binary comparison is produced at all. 302 distinct PRs carry it in 24 hours against 81 that succeed #118708 (mine, open) and #121048 (external, open)
Sync - CH Inc sync (private, not actionable by me)

Mergeable Check and PR are rollups of the two rows above, not separate failures.

Session id: cron:our-pr-ci-monitor:20260920-123139

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 07c65e6

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stateless tests (amd_debug, parallel) and (arm_binary, parallel) / 05227_storage_settings_unknown_name Not from this PR, which touches the aggregate-function state type only. Trunk-wide: the test is mine (added by merged #120898) and three of its expected lines pinned, through a full SHOW CREATE TABLE echo, where an accepted name = DEFAULT query-setting reset is stored; #118423 deliberately moved that. Deterministic, not randomization (the job's own diagnosis reproduces it with and without randomized settings), 801 CIDB rows over 76 pull requests since 05:31Z today, 257 of them on true master #121163 (mine, open)
Finish Workflow / Post Hooks / new_tests_check.py Cascade of the row above: all four Bugfix validation jobs are recorded DROPPED (Dropped due to previous failure [Stateless tests (amd_debug, parallel)]), so none could report OK or XFAIL #121163 (mine, open)
Build profile diff Not from this PR. The job's own read of the CI logs cluster fails, so no binary comparison is produced at all: 332 of 830 runs in 24 hours end error, across 361 distinct pull requests #118708 (mine, open) and #121048 (external, open)
Sync - CH Inc sync (private, not actionable by me)

Mergeable Check and PR are rollups of the rows above.

Session id: cron:our-pr-ci-monitor:20260920-160237

@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 @groeneai, investigate the failure: 03540_system_dashboards times out (600 s) in sanitizer sequential stateless jobs. It is the only new failure behind CH Inc sync here (amd_msan 3/3 and amd_tsan 1/2), and on public master it has failed the same way in Stateless tests (amd_tsan, s3 storage, sequential, 1/2) since 2026-10-04 (e.g. commits 22daf14, 3ead959, b62bc5c, 961b4f7 with pull_request_number = 0 in CIDB), so it is unrelated to this PR. Please provide a fix in a separate PR. If the fix is already in progress, link it here.

@groeneai

groeneai commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator Author

The fix in progress is #123926 (yours, lazy ALIAS resolution in the analyzer). The failures start at 22daf14, the merge commit of #118318.

On #123926's own CI, 03540_system_dashboards took 175-209 s on the four amd_llvm_coverage lanes, against a median of 317-338 s on the same lanes since #118318 and 99-107 s before it (one run per lane). PR CI does not run the full amd_tsan/amd_msan sequential lanes, so I could not measure them there; its CH Inc sync was green.

#123926 does not touch StorageMerge: each of the 97 merge('system', '^metric_log') queries of system.dashboards still deep-copies the ColumnsDescription with about 2190 ALIAS expressions several times (getColumnsDescriptionFromSourceTables, getInMemoryMetadataPtr, the cache key in ReadFromMerge::createChildrenPlans). In my debug build with a lazy-ALIAS analyzer change applied, such a query takes 47 ms vs 24 ms with the wide schema, and these copies are about 60% of its CPU samples. I will send that part as a separate PR and link it here.

@groeneai

groeneai commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator Author

The StorageMerge part is #124115: most of that merge() cost turned out to be a quadratic column lookup in ColumnsDescription::add, not the copies. Since #124011 reverted #118318, 03540_system_dashboards has passed on master (358 runs over 35 commits).

alexey-milovidov and others added 3 commits October 11, 2026 20:35
# Conflicts:
#	src/AggregateFunctions/IAggregateFunction.h
#	src/Columns/ColumnAggregateFunction.cpp
Master added `getStateTypeWithVersionOf` (and the same logic in
`AggregateFunctionTuple::getStateType`), which built the state type of
pass-through combinators from the raw `parameters`. That bypassed
`getStateParameters`, so `argMinIfState(map(1, 2))(...)` and other wrapped
states again carried the unread `Map` parameter, failing
`05180_wrapped_aggregate_state_map_parameter` in Fast test.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=118156&sha=latest&name_0=PR&name_1=Fast%20test
PR: ClickHouse#118156

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Fast test failed on 05180_wrapped_aggregate_state_map_parameter because master added getStateTypeWithVersionOf (and the same versioned path in AggregateFunctionTuple::getStateType). Those build the state type of pass-through combinators from the raw parameters, which skips getStateParameters. I merged master and switched both to getStateParameters in 5cc27ee. With a local build, 05180, 05076 and 04368 now match their references.

`AcceptsStateNameSpellingUnreadParameters` asserted that `DataTypeFactory`
cannot parse the decoded type's name, `AggregateFunction(argMin([(1, 2)]),
UInt8, UInt8)`. Since ClickHouse#121725 taught `parseFieldFromCastedLiteral` to read
`array`/`tuple` parameters, that name parses, so the precondition fails in
all unit test jobs once master is merged.

The precondition only documented which branch of `nameMatchesState` accepts
the Field. The behaviour the test pins does not depend on it: the state type
still drops the unread parameter, both carriers still accept the decoded
Field, and the `argMax` name is still rejected. On master the acceptance now
goes through the parse branch; on a branch without ClickHouse#121725 it goes through
the verbatim comparison.

The headers of 05076 and 05180 no longer claim the parser rejects the name.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

03540_system_dashboards timed out on master again after #124016 re-enabled the bucketed metric_log; #125697 removes the largest remaining cost (the column AST clones in read-only metadata copies).

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 6880b4d

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Build (amd_binary) / (no test row) infra, not from this PR: runner lost mid-compile (log stops at 22:52Z, job closed at 23:03Z with no steps), never re-run (see below) a fix task is created (fixing-PR link to follow here)
Build (amd_debug) / (no test row) infra, not from this PR: runner lost mid-compile (log stops at 22:52Z, job closed at 23:03Z with no steps), never re-run (see below) a fix task is created (fixing-PR link to follow here)
Build (amd_msan) / (no test row) infra, not from this PR: runner lost mid-compile (log stops at 22:54Z, job closed at 23:04Z with no steps), never re-run (see below) a fix task is created (fixing-PR link to follow here)
Build (arm_asan_ubsan) / (no test row) infra, not from this PR: runner lost mid-compile (log stops at 22:53Z, job closed at 23:03Z with no steps), never re-run (see below) a fix task is created (fixing-PR link to follow here)
Build (arm_binary) / (no test row) infra, not from this PR: the build itself finished (Failures: 0/3), then the host Docker daemon died (error waiting for container: unexpected EOF, exit code 125), never re-run a fix task is created (fixing-PR link to follow here)
AST fuzzer (amd_debug, targeted) / (no test row) infra cascade, no test ran: its artifacts from Build (amd_debug) are not in S3 a fix task is created (fixing-PR link to follow here)
AST fuzzer (amd_debug, targeted, old_compatibility) / (no test row) infra cascade, no test ran: its artifacts from Build (amd_debug) are not in S3 a fix task is created (fixing-PR link to follow here)
Quick functional tests / (no test row) infra cascade, no test ran: its artifacts from Build (amd_debug) are not in S3 a fix task is created (fixing-PR link to follow here)
Stateless tests (amd_debug, parallel) / (no test row) infra cascade, no test ran: its artifacts from Build (amd_debug) are not in S3 a fix task is created (fixing-PR link to follow here)
Stateless tests (amd_debug, flaky check) / (no test row) infra cascade, no test ran: its artifacts from Build (amd_debug) are not in S3 a fix task is created (fixing-PR link to follow here)
Stateless tests (amd_binary, flaky check) / (no test row) infra cascade, no test ran: its artifacts from Build (amd_binary) are not in S3 a fix task is created (fixing-PR link to follow here)
Stateless tests (amd_msan, flaky check) / (no test row) infra cascade, no test ran: its artifacts from Build (amd_msan) are not in S3 a fix task is created (fixing-PR link to follow here)
Stateless tests (arm_asan_ubsan, targeted) / (no test row) infra cascade, no test ran: its artifacts from Build (arm_asan_ubsan) are not in S3 a fix task is created (fixing-PR link to follow here)
Unit tests (msan) / (no test row) infra cascade, no test ran: its artifacts from Build (amd_msan) are not in S3 a fix task is created (fixing-PR link to follow here)
Unit tests (msan, function_prop_fuzzer) / (no test row) infra cascade, no test ran: its artifacts from Build (amd_msan) are not in S3 a fix task is created (fixing-PR link to follow here)

The five builds started at 22:43Z on 2026-10-13, in the 22:30-23:00Z wave in which Build jobs errored on about 70 PRs. The automatic retry re-ran one failed build per attempt (Build (amd_asan_ubsan) at attempt 2, Build (amd_tsan) at attempt 3, both green together with their dependent jobs) and stopped at attempt 3, so these five were never re-run and 78 jobs were dropped. The retry policy for this case is asked of the CI owner in #122501. Finish Workflow, Mergeable Check and PR are the rollups of these rows. CIDB has no test FAIL or ERROR row on this head.

Session id: cron:our-pr-ci-monitor:20261014-053008

@groeneai

groeneai commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 223b870

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Upgrade check (amd_release) / Download script failed + Check failed infra, not from this PR: the previous-release .deb downloads from GitHub release assets got 504/503/read timeouts on all 10 attempts during the 2026-11-08 GitHub incident (10 unrelated PRs between 08:56Z and 10:29Z) #130181 (mine, open)
Sync - CH Inc sync (private, not actionable by me)
Mergeable Check, PR praktika rollups of the row above #130181

Session id: cron:our-pr-ci-monitor:20261108-193008

…pe-parameters

Resolved conflicts by keeping the `getStateParameters` overrides of this PR and
adopting the `[[nodiscard]]` annotations from master. Master removed
`forEachNestedFunction`, so it is dropped from `AggregateFunctionTuple.h` too.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-aggregate-functions Aggregate function implementations (sum, avg, count, quantile, combinators, etc.). groeneai-origin-review-bot PR origin: review-bot finding on a groeneai PR pr-bugfix Pull request with bugfix, not backported by default

Projects

None yet

3 participants