Skip to content

Clarify the native protocol docs for revision 54494 (-Merge state versions) - #125115

Merged
alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:groeneai/merge-combinator-state-version-docs
Oct 12, 2026
Merged

alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:groeneai/merge-combinator-state-version-docs

Conversation

@groeneai

@groeneai groeneai commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #123070

Changelog category (leave one):

  • Documentation (changelog entry is not required)

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

Description

Follow-up to #123070, as requested in #123070 (comment): a clearer description of 54494.

Each 54494 row in format.mdx and protocol.mdx now starts with the rule: the state of a -Merge function itself is read at the version of the outer AggregateFunction, not at the version inside its argument type. It then shows the type a shard sends for a distributed quantileDeterministicMerge below and from 54494.

Docs only. Checked over HTTP with client_protocol_version: master at 54493 and 26.9.9.28 at 54492 send the same type string, with no outer version, and a byte-identical payload without skip_degree; master at 54494 spells the outer 1 and adds that byte.

🤖 Generated with Claude Code


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

Version info

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

The rows describing `DBMS_MIN_REVISION_WITH_MERGE_COMBINATOR_STATE_VERSION`
in `format.mdx` and `protocol.mdx` said that a `-Merge` state is written at
version 0 "whatever version the function it merges has", without naming the
column type, without saying that the version belongs to that type rather than
to the merged function, and without describing the reader.

Each row now names the full type of the partial state a shard sends for a
distributed `quantileDeterministicMerge`, states both directions below the
revision (written at version 0; a type string with no outer version is read at
version 0), and says that a version spelled in the argument type does not
apply to the payload. The protocol row also notes that the binary type
encoding always carries the version.

Checked on a debug build of master over HTTP with `client_protocol_version`
54490/54492/54493/54494 (type strings, binary type encoding, payload bytes)
and with a distributed `quantileDeterministicMerge` against 26.9.9.28 in both
directions.

Requested in ClickHouse#123070 (comment)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-review-human PR origin: human review feedback on a groeneai PR labels Oct 10, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 0 findings) plus my own cold review (2 nits). Every claim of the two rows was checked against NativeWriter::setAggregateFunctionStateVersions, NativeReader.cpp setVersionToAggregateFunctions(..., true, server_revision), the gated AggregateFunctionMerge::getVersionFromRevision, DataTypeAggregateFunction::getNameImpl and DataTypesBinaryEncoding.cpp.

# Sev Finding Verdict Evidence / action
1 💡 The format.mdx row links the type-aliases note, which does not mention -Merge AGREE, noted-not-blocking The note carries the version-spelling convention the row relies on; the row itself says the merged function's threshold does not apply

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are
terminal per finding.

Session id: cron:clickhouse-review-slot-10:20261010-230600

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? N/A as a failure repro (docs request, no failing test). Every claim of the new text is checked by a deterministic command: HTTP SELECT ... FORMAT Native with client_protocol_version 54490/54492/54493/54494, type string and binary type encoding, on a debug build of master that contains #123070.
b Root cause explained? The old rows named the subject ambiguously (it could be read as the merged quantileDeterministic states), stated two versions for one payload without saying that the version belongs to the column type, and described only the writer.
c Fix matches root cause? Yes. Each row now names the full -Merge state type and where it occurs, gives both directions below 54494, and says that a version inside the argument type does not apply to the payload.
d Test intent preserved / new tests added? N/A, docs only. Each sentence is tied to an observed byte check or a source line (NativeReader.cpp setVersionToAggregateFunctions(..., true, server_revision), the gated AggregateFunctionMerge::getVersionFromRevision, DataTypeAggregateFunction::getNameImpl).
e Both directions demonstrated? Observed on both sides of the gate (54493: no outer version, no trailing skip_degree; 54494: both) and in both peer directions: a distributed quantileDeterministicMerge between this build and 26.9.9.28 matches the local result either way.
f Fix is general across code paths? Every place that describes revision 54494 was enumerated; the two docs rows are the only ones changed. The code comments of the gate are accurate and untouched.
g Fix generalizes across inputs (params/datatypes/wrappers)? Both column header representations are covered: the type string (version 0 not printed) and the binary type encoding (version always written). Revision 0 stays covered by the existing type-aliases note, which the format.mdx row now links like its siblings.
h Backward compatible? (maintainer-approved exception only) Yes, docs only.
i Invariants and contracts preserved? The table structure is unchanged (same cell count as the neighbouring rows); no generated or read-only docs region is touched; no non-ASCII characters added.

Session id: cron:clickhouse-impl-slot-4:20261010-224600

@clickhouse-gh

clickhouse-gh Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [64c8049]

Summary: ✅


AI Review

Summary

This PR tries to clarify revision 54494 in the native protocol docs, but the new distributed quantileDeterministicMerge(state) example still documents the wrong wire type. The code and existing type-name tests collapse distributed ...MergeState to the nested state type, so the current wording would mislead third-party protocol implementers about what a remote shard actually announces.

Findings
  • ❌ Blockers
    • [docs/resources/develop-contribute/native-protocol/protocol.mdx:163] [dismissed by author -- https://github.com/Clarify the native protocol docs for revision 54494 (-Merge state versions) #125115#discussion_r4243039726] The distributed example still claims that a shard sends AggregateFunction(1, quantileDeterministicMerge, ...), but distributed aggregation goes through ...MergeState, whose result type is the nested state. AggregateFunctionState::createResultType returns nested_->getStateType() and AggregateFunctionMerge::getStateType keeps that collapsed shape, and the existing topKMergeState type-name test prints AggregateFunction(topK(10), String) rather than an outer ...Merge state. As written, the protocol spec now tells readers to expect a wire type that distributed shards do not actually announce.
    • Suggested fix: keep the outer AggregateFunction(...Merge, AggregateFunction(...)) example only for an explicitly declared or stored -Merge state column (the qd_merge_states case in tests/queries/0_stateless/05296_quantile_deterministic_merge_over_network.reference:9), or switch the distributed example to the nested state type that ...MergeState actually announces. The same correction is needed in docs/resources/develop-contribute/native-protocol/format.mdx:328.
Final Verdict

❌ Changes required before merge: the PR’s central clarification still misstates the actual wire type for distributed -Merge aggregation.

@clickhouse-gh clickhouse-gh Bot added the pr-documentation Documentation PRs for the specific code PR label Oct 10, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-documentation Documentation (docs, examples, READMEs). label Oct 11, 2026
The state of a -Merge function is read at the version of the outer
AggregateFunction, not at the version spelled inside its argument type.
Below 54494 that outer version is 0, which is what 26.9 sends: for a
3-row quantileDeterministicMerge state, 26.9.9.28 at revision 54492 and
master at 54493 send the same type string and the same 64-byte payload,
while master at 54494 spells the outer `1` and adds the 1-byte
skip_degree. State this first, with the example type, in both tables.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov alexey-milovidov self-assigned this Oct 12, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 12, 2026
Merged via the queue into ClickHouse:master with commit 40f9df9 Oct 12, 2026
173 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 12, 2026
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-documentation Documentation (docs, examples, READMEs). groeneai-origin-review-human PR origin: human review feedback on a groeneai PR pr-documentation Documentation PRs for the specific code PR 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