Skip to content

Do not declare a type for the sparse offsets stream - #118048

Merged
rienath merged 2 commits into
masterfrom
fix-offsets-data-sparse-serialization
Sep 5, 2026
Merged

rienath merged 2 commits into
masterfrom
fix-offsets-data-sparse-serialization

Conversation

@rienath

@rienath rienath commented Sep 4, 2026 •

Copy link
Copy Markdown
Member

SerializationSparse writes its offsets as VarUInt [1], but declared UInt64 for that stream. The stream is not a subcolumn, so nothing reads the declaration. This PR removes it and adds a regression test.

Motivation: adaptive codec selection (enable_adaptive_codec_selection) picks candidate codecs based on substream's declared type. With UInt64 it tries T64 codec, which never wins for the underlying VarUInt.

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

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

...


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

@clickhouse-gh

clickhouse-gh Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [7288d62]

Summary: ✅


AI Review

Summary

This PR removes the declared UInt64 type from SerializationSparse's SparseOffsets stream and adds a gtest that asserts enumerateStreams no longer exposes one. The code change looks mechanically safe, but I do not see proof that it fixes the PR's stated adaptive-codec issue: SparseOffsets is already excluded from isSpecialCompressionAllowed, and adaptive wrapping only happens on that path, so the new test only covers an internal metadata cleanup.

Tests
  • ⚠️ The PR body says this matters for enable_adaptive_codec_selection, but the new test never exercises that path. Please add a focused end-to-end repro, for example a MergeTree table with ratio_of_defaults_for_sparse_serialization and enable_adaptive_codec_selection enabled, then assert via mergeTreeCodecBlockCounts or another observable that the sparse offsets stream no longer participates in the wrong candidate pool. If there is no user-visible adaptive-codec effect after all, narrow the PR description and motivation to the metadata cleanup this patch actually performs.
Final Verdict
  • Status: ⚠️ Request changes
  • Add regression evidence for the adaptive-codec behavior the PR claims to fix, or narrow the PR contract to the metadata-only cleanup currently covered by the new test.

LLVM Coverage Report

Measured on commit 7288d62.

Metric Baseline Current Δ
Lines 88.70% 88.70% +0.00%
Functions 92.10% 92.10% +0.00%
Branches 81.00% 81.00% +0.00%

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

Full report · Diff report

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

bool offsets_have_type = true;
bool values_have_type = false;
serialization->enumerateStreams(

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.

The PR description claims this fixes enable_adaptive_codec_selection, but this test only checks the internal enumerateStreams metadata. In the current writers, adaptive wrapping only happens under ISerialization::isSpecialCompressionAllowed (src/Storages/MergeTree/MergeTreeDataPartWriterWide.cpp:230-236, src/Storages/MergeTree/MergeTreeDataPartWriterCompact.cpp:95-101), and SparseOffsets is already excluded there (src/DataTypes/Serializations/ISerialization.cpp:562-574). So I can't verify that removing data.type changes any on-disk codec choice. Please add an end-to-end repro around adaptive codec selection, or narrow the PR contract to the metadata cleanup this test actually covers.

@rienath rienath Sep 4, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I do not want to mix adaptive compression in the tests. Verifying type is enough

@clickhouse-gh

clickhouse-gh Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 7288d62c2 with master 48a638b5f (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.

Compile time of recompiled translation units

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

Job report

@clickhouse-gh clickhouse-gh Bot added the comp-data-types Type system & core datatypes used across query planning/execution. label Sep 4, 2026
@rienath
rienath added this pull request to the merge queue Sep 5, 2026
Merged via the queue into master with commit bfd2817 Sep 5, 2026
174 checks passed
@rienath
rienath deleted the fix-offsets-data-sparse-serialization branch September 5, 2026 23:58
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-data-types Type system & core datatypes used across query planning/execution. pr-not-for-changelog This PR should not be mentioned in the changelog 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