Skip to content

Write the empty statistics flag for bucketed Maps in JSON shared data - #118577

Merged
Avogar merged 7 commits into
ClickHouse:masterfrom
rorylshanks:fix/map-statistics-none-json-shared
Oct 8, 2026
Merged

Avogar merged 7 commits into
ClickHouse:masterfrom
rorylshanks:fix/map-statistics-none-json-shared

Conversation

@rorylshanks

@rorylshanks rorylshanks commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Bucketed Map serialization omitted the statistics-presence byte when write_statistics is NONE, while deserializeBucketsInfoStatePrefix always reads it. advanced JSON shared data uses this mode, so runtime maps could consume the first data byte as a flag and fail with CANNOT_READ_ALL_DATA or INCORRECT_DATA.

New parts now write the empty-statistics flag. The reader also recognizes the legacy unversioned layout, including compact parts without substream marks, so parts already written by the feature branch remain readable. Rewrites preserve the disabled-statistics layout and retained runtime Map types.

Regression tests cover new parts, legacy wide and compact parts, and rewrites.

Related: #113022

Failure report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=113022&sha=91ffe2256869399ef0d1de513518842fa44eb60b&name_0=PR&name_1=Stateless%20tests%20%28amd_msan%2C%20flaky%20check%29

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):

Fix reading bucketed runtime Map values from JSON columns using advanced shared-data serialization.


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

Version info

  • Merged into: 26.10.1.1860-master (included in 26.10 and later)
  • Backported to: 26.9.14.7, 26.8.22.7, 26.7.28.7, 26.3.50.6

@rorylshanks rorylshanks closed this Sep 7, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-map-datatype Map datatype implementation and semantics. label Sep 7, 2026
@rorylshanks
rorylshanks deleted the fix/map-statistics-none-json-shared branch September 11, 2026 21:24
rorylshanks and others added 5 commits September 16, 2026 10:26
Honor the existing statistics mode for `Map` reads. Advanced shared data
has no statistics; legacy prefixes omit the flag that corrected writers
include. Seek subsequent substreams using their recorded marks so both
layouts read correctly, including nested maps. Load marks lazily for
whole paths and read their metadata once per granule.

Keep all writers and serialization versions unchanged. Ordinary bucketed
`Map` columns and JSON `map_with_buckets` keep their existing behavior.

Add an actual pre-fix part regression covering full paths, subcolumns,
arrays of maps, nested JSON, and rewriting with the current writer.
It fails on the original CI binary and passes with the changed reader.

Related: ClickHouse#113022
Honor `read_statistics` in the shared `Map` reader while preserving the
released writer layout. Remove the extra statistics flag and the substream
seeking workaround introduced for it. Sequential compact readers now
consume exactly the bytes written, including without substream marks.

Cover compact reads, subcolumns, rewriting, and merging without indexes;
retain the real pre-fix part regression. Update the `Native` specification.

Related: ClickHouse#113022
After `INSERT SELECT` and `OPTIMIZE`, verify runtime types and typed
subcolumn reads for the legacy shared-data and compact-part regressions.
Both tests pass on the current PR binary at
`7801b63bde51d0ec5486a6ab01b6154ea4acc459`.

ClickHouse#113022 (comment)
ClickHouse#113022 (comment)
Only `StatisticsMode::NONE` omits both the presence flag and payload.
`StatisticsMode::PREFIX_EMPTY` writes a false flag without the payload.
These part-storage streams remain separate from the `Native` wire format.

ClickHouse#113022 (comment)
@rorylshanks rorylshanks reopened this Sep 16, 2026
@clickhouse-gh clickhouse-gh Bot added comp-json-datatype JSON/Dynamic/Object datatype: semi-structured column storage, typed and dynamic paths, sub-object... and removed comp-map-datatype Map datatype implementation and semantics. labels Sep 16, 2026
rorylshanks added a commit to rorylshanks/ClickHouse that referenced this pull request Sep 16, 2026
Keep runtime-type and indexed-query coverage while the bucketed `Map` reader fix remains separate. Remove the pins after the reader fix merges.

Related: ClickHouse#118577

Related: ClickHouse#113022
@Avogar Avogar self-assigned this Oct 7, 2026
@Avogar Avogar added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Oct 7, 2026
@rorylshanks

Copy link
Copy Markdown
Contributor Author

Hey @Avogar can you add 'can be tested' and approve the workflow?

@rienath rienath added the can be tested Allows running workflows for external contributors label Oct 8, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [c5423cf]

Summary: ✅


AI Review

Summary

This PR extends the deserialization statistics gate to bucketed Map prefixes and threads the disabled-statistics setting through the advanced JSON shared-data read paths, so runtime Map values in shared data no longer consume payload bytes as a statistics flag. I did not find a correctness, compatibility, or performance issue in the current diff, and the added coverage exercises new parts, legacy wide parts, compact parts without substream marks, and rewrite paths.

Final Verdict

✅ No blocking issues found in the current diff; no new inline review comments.

LLVM Coverage Report

Measured on commit c5423cf.

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

Changed lines: Changed C/C++ lines covered: 27/27 (100.00%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Oct 8, 2026
@Avogar
Avogar added this pull request to the merge queue Oct 8, 2026
Merged via the queue into ClickHouse:master with commit 339df1c Oct 8, 2026
152 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Oct 8, 2026
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 8, 2026
clickhouse-gh Bot added a commit that referenced this pull request Oct 8, 2026
Backport #118577 to 26.9: Write the empty statistics flag for bucketed Maps in JSON shared data
clickhouse-gh Bot added a commit that referenced this pull request Oct 8, 2026
Backport #118577 to 26.8: Write the empty statistics flag for bucketed Maps in JSON shared data
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Oct 9, 2026
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Oct 9, 2026
PedroTadim added a commit that referenced this pull request Oct 12, 2026
Backport #118577 to 26.7: Write the empty statistics flag for bucketed Maps in JSON shared data
robot-clickhouse added a commit that referenced this pull request Oct 12, 2026
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Oct 12, 2026
PedroTadim added a commit that referenced this pull request Oct 12, 2026
Backport #118577 to 26.3: Write the empty statistics flag for bucketed Maps in JSON shared data
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-json-datatype JSON/Dynamic/Object datatype: semi-structured column storage, typed and dynamic paths, sub-object... pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-bugfix Pull request with bugfix, not backported by default pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync 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.

5 participants