Skip to content

Always print aggregate function parameters with types - #121725

Merged
alexey-milovidov merged 10 commits into
ClickHouse:masterfrom
groeneai:remove-should-print-parameters-with-types
Oct 11, 2026
Merged

alexey-milovidov merged 10 commits into
ClickHouse:masterfrom
groeneai:remove-should-print-parameters-with-types

Conversation

@groeneai

@groeneai groeneai commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #121491

Changelog category (leave one):

  • Improvement

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

An aggregate function parameter whose value has no unambiguous bare literal form, such as a Decimal, a wide integer, a UUID, an IPv4/IPv6 or a non-negative Int64, is now always printed with an explicit ::Type suffix, and inside an array or tuple parameter the suffix goes on the elements. Such a parameter therefore reads back as the same Field for every family, instead of only for the ones that had opted in. The name also travels over the Native protocol, so an insert into a column whose parameter was spelled without the type is now rejected there too, as it already was locally.

Description

DataTypeAggregateFunction::formatParameters picked one of two Field printers per function, through the virtual shouldPrintParametersWithTypes(). Opting in kept the name reading back as the same parameters, so the list was an unfinished audit: it grew twice (#119810, #121491) and still missed groupArrayInsertAt and sumMapFiltered, both covered below. This deletes the hook and always uses FieldVisitorToCastedLiteral.

Which names change: only a parameter with no unambiguous bare literal form, or a composite holding one. Everything else is byte-identical: the visitor runs with skip_unambiguous_cast = true. Measured: sumMapFiltered(['1']) becomes sumMapFiltered(['1'::Decimal32(1)]), topK(10) does not move, and only #121491's .reference moves.

The suffix lands on the ELEMENTS of a composite, which parseFieldFromCastedLiteral did not accept, so printing typed alone would have broken a working DETACH/ATTACH of sumMapFiltered([toDecimal32(1, 1)]); the reader therefore gains a recursive array/tuple branch.

In a Replicated database, CREATE TABLE ... AS SELECT of such a state re-created the column from the untyped name and failed with CANNOT_CONVERT_TYPE; it now succeeds, as does test 05211 on DBReplicated runs.

Compatibility, measured. A scalar suffix reads back on 26.6+, so only 26.5 and older reject one, pre-existing (quantile #119810, timeSeries*). The composite spelling is new, so no released version reads it: a mixed-version distributed query over such a state, or a downgrade, gets BAD_ARGUMENTS. Between two current servers the name also decides which inserts are accepted: an insert into a Decimal-parameter column starts working, one into a String-parameter column stops, as it already did locally and under binary type encoding.

Out of scope: DataTypeCustomSimpleAggregateFunction; the EXPLAIN and system.query_log printers, never reparsed; an Object parameter, still untyped; a Map, printed as an array, so its entries take suffixes and read back as an Array.

The insert matrix, measured on two servers, one binary per arm

The source is CREATE TABLE ... ENGINE = Memory AS SELECT groupArrayInsertAtState(toDecimal32(1.5, 1), 3)(x, i), so its parameter is a Decimal Field. The String destination declares the same column with '1.5', which is how a server without this change persists that type. Each accepted cell is confirmed by reading the state back with finalizeAggregation.

source parameter destination parameter path before after
Decimal String remote() accepted CANNOT_CONVERT_TYPE
Decimal String one server CANNOT_CONVERT_TYPE CANNOT_CONVERT_TYPE
String String remote() accepted accepted
Decimal Decimal remote() CANNOT_CONVERT_TYPE accepted

Before the change all four columns print the same name, so the rejection in the last row names one type twice. NativeWriter sends type->getName() and NativeReader rebuilds the type from it, so the lossy name degraded a Decimal parameter to a String on the receiving side and strictEquals compared that degraded value. native.encode_types_in_binary_format encodes each parameter as a typed Field, so it already behaved as the last two rows do now.


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

Version info

  • Merged into: 26.10.1.2115-master (included in 26.10 and later)

groeneai and others added 8 commits September 23, 2026 01:48
DataTypeAggregateFunction::formatParameters chose between two Field printers
per aggregate function, through the virtual
IAggregateFunction::shouldPrintParametersWithTypes(). A function had to opt in
to having its parameters printed in a form that reads back as the same Field,
so the opt-in list was an unfinished audit rather than a behaviour toggle: it
was extended for quantile in ClickHouse#119810 and for eight more families in ClickHouse#121491,
and it still missed exponentialTimeDecayed{Sum,Max,Count,Avg}.

FieldVisitorToCastedLiteral is constructed with its default
skip_unambiguous_cast = true, so it already suppresses the ::Type suffix
wherever the bare literal reparses to the same Field. Comparing it with
FieldVisitorToString, the printed text differs only for a non-negative Int64,
a wide integer, a UUID, an IPv4/IPv6 and a DecimalField, plus an Array, Tuple
or Map holding one of those. The hook therefore only ever chose between
"always correct" and "correct unless a parameter happens to carry one of those
types", which is what makes it removable rather than a user-facing option.

Because the only use of the IAggregateFunction argument was the hook call, the
argument is dropped and the signature reduces to formatParameters(parameters).

The visitor suffixes the ELEMENTS of a composite value, so a composite
parameter now prints as a call over literals, for example
sumMapFiltered(['1'::Decimal32(1)]). parseFieldFromCastedLiteral accepted only
an ASTLiteral or a top-level CAST, so that name throws BAD_ARGUMENTS while the
untyped spelling parses. Printing typed without extending the reader would
convert a working DETACH/ATTACH of sumMapFiltered([toDecimal32(1, 1)]) into a
hard failure, so the parser gains a recursive branch for the two composite
shapes the visitor emits. A Map parameter still reads back as an Array, which
it already does today in both visitors.

The <algorithm> include in AggregateFunctionTuple.cpp was added by d9c814e
for the std::ranges::any_of of the deleted override and has no other user in
that translation unit; the FieldVisitorToString.h include in
DataTypeAggregateFunction.cpp likewise loses its only user.

Requested in ClickHouse#121491 (comment)
…entence and test

ClickHouse#121491 landed while this branch was in progress. It added nine more
shouldPrintParametersWithTypes overrides, a NativeFormat sentence describing the
::Type suffix as a property of the aggregate function, and a test arm asserting
that a composite parameter keeps an untyped spelling because a suffix inside a
composite does not parse back.

With the hook gone the overrides have nothing to override, so they are deleted
along with their comments; the docs sentence now states the rule the code
actually follows, which is that the suffix depends on the parameter's value and
lands on the elements of a composite; and the composite arm of
05211_aggregate_parameter_type_name_round_trip expects the typed spelling, its
DETACH/ATTACH assertion unchanged, because the recursive array/tuple branch in
parseFieldFromCastedLiteral is what makes that name readable.
The reader this branch adds has two result paths, array and tuple, and every
composite fixture in 05238 and in 05211 was an array, so the tuple path in
parseFieldFromCastedLiteral had no test. The validation notes asserted that
both printed tuple spellings work; nothing stood behind that assertion.

Both new arms use groupArrayInsertAt, whose first parameter is a default value
of the argument type, so a Tuple default is reachable from ordinary SQL: a
Tuple(Decimal32(1), UInt64) default prints as ('1.5'::Decimal32(1), 7), which
parses as a call of tuple, and a Tuple(Decimal32(1)) default prints as
tuple('1.5'::Decimal32(1)), which is a different printed shape. Both run
through the oracles the file already had, so no oracle line was added. The
empty-tuple spelling is deliberately left out: it works, but it is a third
spelling for a degenerate type.

Proven live rather than assumed. With only the tuple result path replaced by a
throw, 05238 fails at that throw while parsing groupArrayInsertAt, and the
typed_array column that sits before the tuple columns still parses, so the
array path is untouched and the rejection belongs to the new arms.

This also corrects the cross-version answer in the pre-PR validation notes,
which claimed the exposure was wholly pre-existing. Measured per release
branch, it has two halves: the scalar ::Type suffix has been readable since
26.6, but the composite array/tuple spelling is new in this commit and no
released version parses it, so a mixed-version distributed query over such a
state, or a downgrade, gets BAD_ARGUMENTS. The description already said this;
the notes did not.

Co-Authored-By: Claude Opus 5 <[email protected]>
The name of an aggregate function state is what crosses the Native protocol:
NativeWriter sends type->getName() and NativeReader rebuilds the type from
that name through the data type factory, so this branch's printer change
decides whether a state sent between two servers still compares equal to the
destination column. Nothing in the suite exercised that path. 05238 covers the
metadata carrier only: a declared column, a query-built state,
initializeAggregation, DETACH and ATTACH, all inside one server.

The new test inserts a state with a Decimal parameter through remote() into a
column declared from the same expression. prefer_localhost_replica = 0 is what
makes that a real connection rather than a local plan: SelectStreamFactory
takes the local shortcut only when the setting is on and the shard is local,
and isLocalAddress requires the port to match, so a self-addressed remote()
with the setting off still goes over the wire. One server is therefore enough.

It covers the direction this branch starts accepting. Before, the untyped name
degraded a Decimal parameter to a String on the receiving side, so the insert
was rejected with CANNOT_CONVERT_TYPE naming the same type twice; the previous
binary fails the new test at exactly that point, inside
RemoteQueryExecutor::processPacket, which is also what proves the hop is real.
The opposite direction, a typed state into a column whose parameter genuinely
is a String, stops being accepted. That one is deliberately not pinned: whether
the new acceptance set is the intended contract is not mine to assert.

Also makes the formatParameters comment say where the suffix lands. A composite
value carries no suffix itself, its elements do, which is the property the
recursive reader branch exists for.
05239 asserted the destination's typed state name and finalizeAggregation,
and neither depends on how the state arrived: running the test with
prefer_localhost_replica = 1 produced the reference byte for byte. The
carrier the test exists for was pinned only by a SETTINGS clause whose
effect nothing checked, so if that clause were ever dropped or made a
no-op the test would keep passing as a weaker duplicate of 05238.
prefer_localhost_replica is also randomized by the runner, which is what
makes the query-level clause load-bearing.

Key the INSERT with log_comment and assert that a secondary query was
logged, the idiom 04366_secondary_query_internal_flag_propagation.sh
already uses for the same reason. A local shortcut dispatches none, so
flipping prefer_localhost_replica to 1 now flips the new line from 1 to 0
while the other two lines stay identical.

parseFieldFromCastedLiteral accepts array(...) and tuple(...) since this
branch, but its BAD_ARGUMENTS message still enumerated only a literal and
a CAST of a literal, so a user hitting it on a composite read an
incomplete list. No test or reference asserts that text; the one other
mention is a prose comment in 05079, whose assertion matches the error
code.
Review round 5. Comment accuracy only: no behaviour change, no added lines,
no new test. The rebuilt binary has the same Build ID as before the round,
which is the mechanical proof of that; comments do not survive the
preprocessor, so every dependent translation unit recompiled to a
byte-identical object and the linked image is identical.

DataTypeAggregateFunction.h: the doc comment on formatParameters stated a
universal rule that the code does not keep. Three Field types print through
FieldVisitorToString with no ::Type suffix (Object, AggregateFunctionStateData,
CustomType), and parseFieldFromCastedLiteral has no target for any of them, so
none round-trips. Behaviour there is byte-identical to master, because the
non-opted-in functions already used FieldVisitorToString: only the sentence was
wrong. It now attributes the suffix to FieldVisitorToCastedLiteral and says
"where the type has one", which is what excludes those three, rather than
promising it for every value. The composite clause is kept deliberately: it is
the reason the coupled reader change exists and is not derivable from the
declaration below it.

05239_aggregate_parameter_types_native_hop.sh: the comment explaining
prefer_localhost_replica = 0 named isLocalAddress, an internal C++ symbol. A
test should not reach into the implementation, since that couples it to code it
cannot see and goes stale silently. Reworded to state the observable behaviour
instead: a same-host, same-port shard is otherwise served locally, so there is
no Native hop to cross. The script body, its settings, its log_comment and its
reference file are unchanged, and the file is still 39 lines.

The one remaining isLocalAddress reference under tests/ is in
04050_skip_unavailable_shards_local_missing_table.sql, which this PR does not
touch, so it is left alone.

Validation: warm incremental build RC=0 (14574 targets, relink);
05239 [ OK ] 1.33 sec on the rebuilt binary, with the server's buildId()
asserted equal to readelf's; ci/jobs/check_style.py output byte-identical to
the previous round (its one failing leg needs CI's changed-files hook).
Drop the array/tuple branch's design narration, cut the header bullet to the grammar and the Map-reads-back-as-Array property, and state formatParameters' spelling as an invariant.
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-request PR origin: a maintainer pinged or directed groeneai labels Sep 23, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review

An independent model reviewed this diff cold and a separate pass adjudicated its findings against the
measurements; six rounds, the tree went back after each of the first five. Only the declined findings are
listed, since those are the ones a reviewer may want to overrule me on. The rest were agreed and fixed in the
diff you see.

Declined, each on a measurement rather than on scope:

Finding Verdict
❌ Preserve compatibility between the legacy and the canonical parameter representation, so a faithful name still inserts into a column whose metadata kept the lossy spelling. Declined on the measurement: the same insert without remote() was already rejected before this change, so the Native acceptance was the anomaly, and the binary type encoding already sends the parameter as a typed Field; the matrix is in the description, so the boundary stays your call.
❌ The new spelling reaches older peers with no protocol-revision gate. Add a revision and keep the legacy spelling below it. Raised in three rounds; true, and in the description with the measurement. Keeping the legacy spelling for an old peer means deliberately sending a name that reparses to a String where the payload holds a Decimal, which is the degradation this change removes, and the two earlier widenings of this surface shipped ungated; the failure mode is a loud BAD_ARGUMENTS. Wire-compatibility policy is yours to set.
❌ The wire test never pins the other direction: a Decimal state going into a column whose parameter was spelled as a String is now rejected, and nothing asserts that. True and deliberate: that is the backward-incompatible half, so pinning it would assert as intended contract the one thing you may want ruled differently. 05079 pins the local direction and 05239 fails with CANNOT_CONVERT_TYPE without the change. Say the word and I will pin the rejection too.
❌ A Map parameter round-trips as an Array, so a family that reads one rejects its own printed name. Real but not from this change: on master the same name fails to parse at all (Code: 36), because a nested collection literal is not folded. Spelling a Map apart needs a change to a shared visitor and to the reader.
❌ Disable Native binary type encoding in the wire test, so the printed name is provably the carrier. Declined on a measurement: the setting is off by default, appears nowhere in clickhouse-test so no leg randomizes it, and the server's own result writer reads it for inter-server traffic too; pinning it would guard a default nothing flips.
💡 05079_parse_aggregate_function_typed_param.sql still quotes the parse error text this PR widened, and cites a line number the diff moved. Declined on scope: that file is master's and untouched here, its assertion matches the error code rather than the text, and it passes on the new binary. Named so nobody greps for a string that no longer exists.

Agreed and fixed across the six rounds: a missing typed-tuple arm in 05238, with a negative control that
disables only the tuple path · a cross-version paragraph that called the whole exposure pre-existing · a
changelog entry in bug-fix voice · the undisclosed insert-acceptance change between two current servers, now
carried as a measured matrix · the wire having no test behind it, now a remote() round trip that fails with
CANNOT_CONVERT_TYPE without this change · that test passing on the local shortcut, now also asserting a
secondary query was dispatched · the out-of-scope list's claim that a Map prints untyped · a parse error
message offering only literals and casts · formatParameters's doc comment, whose value-level rule did not
allow for the Object, state and custom Field arms · a test comment naming an internal C++ symbol instead of
the behaviour it explains · a description that named a window-only family as the audit's missed case.

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (a-i)
# Check Result
a Deterministic repro One clickhouse local --queries-file run, no randomization and no timing: toTypeName(groupArrayInsertAtState(toDecimal32(1.5, 1), 3)(x, i)) prints groupArrayInsertAt('1.5', 3) before and groupArrayInsertAt('1.5'::Decimal32(1), 3) after.
b Root cause The printer was chosen per FAMILY by a virtual hook, while the ambiguity is a property of the parameter's Field type, a test FieldVisitorToCastedLiteral already performs internally through skip_unambiguous_cast = true.
c Fix matches root cause The per-family switch is deleted rather than worked around, and the reader is widened to every shape the writer can emit; no widened bound, no no-random-* tag, no guard at a symptom site.
d Test intent preserved, new tests added Two new stateless tests: five typed arms (scalar Decimal, UUID, a typed array, both printed tuple spellings) plus an unambiguous control arm that must stay bare, and a Native-carrier test crossing remote() under prefer_localhost_replica = 0; #121491's composite arm keeps asserting its round trip.
e Both directions [ OK ] with the change and [ FAIL ] return code: 36 without it, thrown at the exact line changed; the Native test reddens on base with Code: 70 CANNOT_CONVERT_TYPE from RemoteQueryExecutor.cpp:458, a frame a local plan does not have, so its redness also proves the hop is real.
f General across code paths All ten carriers of "a printed parameter reparses to the same Field" walked: writer changed, metadata/Native/distributed reader changed, ColumnAggregateFunction::getTypeString inherits it by delegation, the Tuple-combinator pass-through deleted with the hook, binary type encoding immune.
g Generalizes across inputs Driven by Field type, each measured: UInt64, Float64, String, bool and negative Int64 unchanged; non-negative Int64, wide integers, UUID, IPv4/IPv6 and Decimal32..256 suffixed; Array/Tuple/Map recursively.
h Compatibility, measured No setting, no SettingsChangesHistory.cpp entry, no state version bump, no serialization change; the scalar suffix is pre-existing and readable from 26.6 on, the composite spelling is new so a mixed-version distributed query or a downgrade gets BAD_ARGUMENTS, and between two current peers an insert into a Decimal-parameter column starts being accepted while one into a String-parameter column stops, as it already did locally.
i Invariants and contracts Strictly strengthened: the new branch rebuilds an Array as Array and a Tuple as Tuple in element order with Decimal scales preserved, proven by finalizeAggregation after DETACH/ATTACH, and guards recursion with checkStackSize(); a negative control that disables only the tuple result reddens the test, and the pre-existing control rejecting quantile(someColumn) still rejects it.

Verification: 50/50 randomized runs of each new test green; the 58 existing test files that mention a
parameterized aggregate state name were run against both binaries, and no test fails with the change that
does not also fail without it; check_style.py 16/17 legs pass, the one failure being a harness leg that
cannot see changed files outside praktika.

@clickhouse-gh

clickhouse-gh Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [c02ff20]

Summary: ✅


AI Review

Summary

This PR replaces the per-family aggregate-parameter audit with value-driven printing and teaches the parser to read typed elements inside array and tuple parameters, which fixes several real round-trip failures. I would still block it as written, because it also changes the AggregateFunction(...) name grammar that is persisted in metadata and sent over Native / remote() with no revision gate or compatibility setting, so mixed-version hops and downgrade paths now break.

PR Metadata
  • Changelog category: the current Improvement label is not correct for the code as submitted, because the new composite parameter spelling is unreadable by older servers on mixed-version Native hops and after downgrade. Exact replacement: - Backward Incompatible Change.
  • Changelog entry: it is required and otherwise detailed, but if the change remains ungated it should surface the compatibility break directly. Suggested replacement: Aggregate-function parameters whose values lack an unambiguous bare literal form are now persisted and sent with explicit ::Type suffixes, including inside array and tuple parameters. Older servers cannot read the new composite parameter spelling on mixed-version native/distributed hops or after downgrade.
Findings
  • ❌ [src/DataTypes/DataTypeAggregateFunction.cpp:103] [dismissed by author -- https://github.com/Always print aggregate function parameters with types #121725#issuecomment-5793630841] formatParameters now emits typed array/tuple elements unconditionally for every AggregateFunction state name. That spelling is persisted in metadata and also sent over Native / remote() via ColumnAggregateFunction::getTypeString, but older servers do not parse typed composite elements, so mixed-version distributed hops and downgrade paths now fail with BAD_ARGUMENTS. The fact that the legacy spelling was already lossy locally does not provide a migration path for older readers.
    Suggested fix: gate the new composite spelling on a protocol revision or compatibility setting and keep emitting the legacy form to older readers; otherwise treat this as an explicit backward-incompatible format change with a documented migration path.
Final Verdict
  • Status: ❌ Block
  • Minimum required actions: add a compatibility gate / migration path for the new composite parameter spelling, or deliberately make this a backward-incompatible change and update the upgrade story plus changelog metadata accordingly.

LLVM Coverage Report

Measured on commit c02ff20.

Metric Baseline Current Δ
Lines 88.30% 88.30% +0.00%
Functions 91.80% 92.10% +0.30%
Branches 79.70% 79.70% +0.00%

Changed lines: Changed C/C++ lines covered: 65/66 (98.48%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Sep 23, 2026
@groeneai
groeneai requested review from Avogar and vitlibar September 23, 2026 09:21
@clickhouse-gh clickhouse-gh Bot added the comp-aggregate-functions Aggregate function implementations (sum, avg, count, quantile, combinators, etc.). label Sep 23, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

On the Changelog category request. The compatibility break is real, I measured it, and the insert matrix is in the description, so I am not arguing with the premise. I have not flipped the category myself, because both verdict lines are the same decision and that one is not mine to take.

Gate the spelling behind a revision or a compatibility setting and there is no break to declare, so Improvement stands. I declined that remedy on a measurement rather than on principle: keeping the legacy spelling for an older reader means deliberately sending a name that reparses to a String where the payload holds a Decimal, which is already rejected inside a single server and already sent typed when output_format_native_encode_types_in_binary_format is on, and the only place a shim could live is strictEquals, shared with state merge, CAST compatibility and aggregate projection matching.

Keep the break intentionally and Backward Incompatible Change is the honest label. Say the word and I will set the category and fold the compatibility sentence into the entry; that is a body edit and needs no push.

Three measured bounds, so the call rests on numbers rather than on my summary. The scalar ::Type suffix is not new: it reads back on 26.6 and later, and it shipped in #119810 and #121491, both merged as bug fixes without that label. The composite spelling inside an array or a tuple is new here, and no released version parses it. A table created before the upgrade keeps the spelling in its own metadata file and still loads, so the exposure is a new CREATE, a hop to an older peer, or a downgrade.

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - e9418b6

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
Stress test (amd_debug) / Logical error: Unexpected return type from A. Expected B. Got C. Action: (STID: 1611-45e7) trunk logical error, not PR-caused: Unexpected return type from plus. Expected UInt64. Got Int64 on FUNCTION plus(plus(value, 1_UInt8), value), the lambda-argument-shadows-an-outer-column visit-order defect in the planner's actions visitor. 39 rows across 33 distinct pull requests, 8 check flavours and 5 true-master runs in 30 days, the whole population since 2026-09-19 08:07Z. The sibling shards agree it is not this build: the other nine Stress flavours on this head all report Failures: 0/4 #121230 (external, open)
Performance Comparison (arm_release, master_head, 4/6) dashboard-only verdict, not PR-caused: shard summary 4 too long, 1 unstable; 1 confirmed regression(s) on the performance dashboard, with no "slower" phrase at all, so the shard's own report called no query slower and in master_head mode the dashboard arm is then the only FAIL source. 821 such job reds across 386 distinct pull requests and 0 true-master runs in 7 days #121847 (external, open)
Mergeable Check aggregator row, mirrors the two rows above, no independent failure #121230 and #121847 (both open)
PR aggregator row, mirrors the two rows above, no independent failure #121230 and #121847 (both open)

Measured at this head, not inherited: across the whole commit there is exactly one FAIL/ERROR
test row, the stress logical error in row 1. CH Inc sync is green here, so nothing is exempt.

Neither row can come from this diff. Row 1 aborts inside the planner while building actions for
plus under a lambda; this PR changes aggregate-function parameter type printing and parsing
(IAggregateFunction, DataTypeAggregateFunction, parseFieldFromCastedLiteral and the
per-function overrides), touches no lambda, ColumnFunction or actions-DAG code, and the same
signature fires on plain master five times in the same window. Row 2 is decided by the perf
dashboard, which this diff does not participate in.

On row 1's owner: my own earlier fix for this signature, #115005, was closed on 2026-09-21 as
superseded by #121230, which repairs the same ordering defect from the visitColumn side so that an
outer column colliding with a lambda argument is no longer registered as an input under that name.
#121230 is the live fix, so I link it rather than the closed PR.

Session id: cron:our-pr-ci-monitor:20260923-203258

groeneai and others added 2 commits October 7, 2026 12:27
…-parameters-with-types

Conflicts:
- AggregateFunctionTuple.{h,cpp}: keep master's new isOnlyWindowFunction override and drop the
  shouldPrintParametersWithTypes one. Keep #include <algorithm>, which isOnlyWindowFunction now uses.
- NativeFormat.mdx moved to docs/resources/develop-contribute/native-protocol/format.mdx; the
  parameter-spelling sentence is re-applied on master's text there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The comment trim dropped "where its type has one", which made the rule
universal. Object, AggregateFunctionStateData and CustomType parameters are
printed through FieldVisitorToString with no suffix, so the unqualified sentence
was false for them. Comment only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
stream << applyVisitor(FieldVisitorToCastedLiteral(), parameters[i]);
else
stream << applyVisitor(FieldVisitorToString(), parameters[i]);
stream << applyVisitor(FieldVisitorToCastedLiteral(), parameters[i]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ This makes the new composite ::Type spelling unconditional for every AggregateFunction(...) state name, but there is still no protocol-revision or compatibility gate around it. Older servers do not parse typed elements inside array/tuple parameters, so a mixed-version remote()/distributed hop or a downgrade starts failing with BAD_ARGUMENTS as soon as a state name like groupArrayInsertAt(['1'::Decimal32(0)], 3) crosses the boundary.

Please negotiate the new spelling behind a revision / compatibility setting and keep emitting the legacy header to older readers, or treat this as an explicit backward-incompatible format change with a migration path.

@clickhouse-gh

clickhouse-gh Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

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

✅ No significant changes.

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

152 object files changed (-825.26 KiB total), 0 added.

Object file Master PR Δ
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionQuantileExact… 6.61 MiB 6.53 MiB -83.96 KiB (-1.24%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionQuantile.cpp.o 3.65 MiB 3.61 MiB -40.95 KiB (-1.10%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionQuantileInter… 3.47 MiB 3.43 MiB -40.84 KiB (-1.15%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionQuantileGK.cp… 3.28 MiB 3.24 MiB -35.45 KiB (-1.06%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionQuantileDeter… 2.78 MiB 2.74 MiB -34.03 KiB (-1.20%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionGroupArrayMov… 5.80 MiB 5.77 MiB -32.46 KiB (-0.55%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionGroupNumericI… 7.37 MiB 7.34 MiB -30.20 KiB (-0.40%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionTopK.cpp.o 3.28 MiB 3.25 MiB -26.13 KiB (-0.78%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionAvgWeighted.c… 13.35 MiB 13.33 MiB -19.18 KiB (-0.14%)

719 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.

Compile time of recompiled translation units

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

Job report

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I like it.

@alexey-milovidov alexey-milovidov self-assigned this Oct 11, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 11, 2026
Merged via the queue into ClickHouse:master with commit 46dfb81 Oct 11, 2026
152 checks passed
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 11, 2026
valerypetrov added a commit to valerypetrov/ClickHouse that referenced this pull request Oct 11, 2026
Master removed IAggregateFunction::shouldPrintParametersWithTypes in ClickHouse#121725 and now always prints aggregate function parameters with types, so the override no longer compiles after the master merge.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Oct 13, 2026
`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 added a commit to groeneai/ClickHouse that referenced this pull request Oct 24, 2026
…state-constant-identity

Resolve the conflict with ClickHouse#121725, which removed the `function` argument of
`DataTypeAggregateFunction::formatParameters`: `getAggregateFunctionNames`
now spells the parameters with the one-argument form, as `getNameImpl` does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
thevar1able added a commit that referenced this pull request Nov 14, 2026
Parameters of `AggregateFunction` are printed with their types only since
#121725, which is not in 26.8.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
thevar1able added a commit that referenced this pull request Nov 14, 2026
Parameters of `AggregateFunction` are printed with their types only since
#121725, which is not in 26.9.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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-request PR origin: a maintainer pinged or directed groeneai pr-improvement Pull request with some product improvements pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants