Skip to content

Cherry pick #112934 to 26.3: Keep Iceberg statistics for supported columns when a field type is unsupported - #121532

Merged
robot-ch-test-poll2 merged 5 commits into
backport/26.3/112934from
cherrypick/26.3/112934
Sep 24, 2026
Merged

robot-ch-test-poll2 merged 5 commits into
backport/26.3/112934from
cherrypick/26.3/112934

Conversation

@robot-clickhouse

Copy link
Copy Markdown
Member

Original pull-request #112934

Do not merge this PR manually

This pull-request is a first step of an automated backporting.
It contains changes similar to calling git cherry-pick locally.
If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.

The check results does not matter at this step - you can safely ignore them.

Before you resolve anything

Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.

Troubleshooting

If the conflicts were resolved in a wrong way

If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

groeneai and others added 4 commits August 1, 2026 16:12
…supported

An INSERT into an Iceberg table whose schema contains a column that cannot be
serialized into a statistics bound wrote no lower_bounds/upper_bounds at all for
the data file, losing the bounds of every supported column too. Those maps drive
min/max file pruning, so one Array/Map/Tuple/Decimal/Float/UInt* column silently
disabled file-level pruning for the whole table, for ClickHouse's own reader and
for external readers alike.

canWriteStatistics was a whole-vector predicate: it returned false on the first
field whose bound canDumpIcebergStats rejects, and its two callers used that as
an all-or-nothing gate. Skipping set_fields leaves the Avro union on its null
branch, which surfaces as an empty map. A column that is entirely NULL trips the
same veto, because ColumnNullable::getExtremes yields POSITIVE_INFINITY, a Field
of type Null.

Replace it with filterWritableStatistics, which returns the subset of bounds that
can be serialized; the callers write that subset when it is non-empty. An omitted
field is simply absent from the map, which readers already treat as "bound
unknown" and skip (ManifestFileIterator, ManifestFilesPruning), and the
compaction path already emits such partial maps. The partition-summary path in
this same file already performs the identical per-field skip with the same
predicate, so the data-file path becomes consistent with its sibling. When no
field is serializable, nothing is written, exactly as before.

The gate deliberately stays canDumpIcebergStats rather than "does
dumpFieldToBytes support it": the byte dumper handles a strictly wider set and
throws LOGICAL_ERROR on the rest, so filtering now guarantees that precondition
by construction instead of relying on the veto having covered every element.

Measured per release branch: 26.7, 26.6, 26.5 and 26.3 reproduce; 25.8 has no
allow_insert_into_iceberg. The introducing commit is not identified.

Closes #112706

Co-Authored-By: Claude Fable 5 <[email protected]>
Resolves the conflict with #112414, which merged first and renamed the statistics
source in generateManifestFile from data_file_statistics to effective_statistics.
The resolution keeps this branch's per-field filterWritableStatistics mechanism
and applies it to the new source, so both call sites read
effective_statistics->getLowerBounds()/getUpperBounds() through the filter.

#112414 added 04652_iceberg_insert_per_file_statistics, whose reference asserted
the all-or-nothing output this branch fixes: the two data files holding an
all-NULL score recorded lower=[] upper=[], dropping the bound of the id column
along with it. Those two rows now carry the id bound, [(1,2)] and [(1,3)]. Its
comments described that loss as pre-existing behaviour asserted rather than
fixed, which no longer holds, so they now state the per-field rule instead.

Renamed the new test from 04693 to 04739. Master took 04693 for five unrelated
tests while this branch was open, and check_gaps_in_tests_numbers only flags
gaps, never collisions, so a duplicate number ships silently under green CI.
04739 is free on master, across all 2077 open pull requests and in the fleet
worktrees.

Co-Authored-By: Claude Opus 5 <[email protected]>
…tatistics-bounds

Keep Iceberg statistics for supported columns when a field type is unsupported
@robot-clickhouse robot-clickhouse added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default labels Sep 22, 2026
@groeneai

Copy link
Copy Markdown
Collaborator

The "the bot re-tries this cherry-pick" note above does not apply here, so this one will not resolve itself.

Both conflicting regions are #112414 content, and #112414's own 26.3 cherry-pick (#119455) was closed unmerged on 2026-09-14. 26.3 has neither 04652_iceberg_insert_per_file_statistics.sh nor its .reference, and generateManifestFile there reads the bounds from data_file_statistics, not from the effective_statistics that #112414 introduced. The prerequisite is declined rather than pending, so every retry will conflict the same way.

The bug itself is present on 26.3 though. canWriteStatistics there is byte-identical to the master function this PR replaces, and its two call sites gate lower_bounds/upper_bounds on it in the same all-or-nothing way, so one column whose type cannot be serialized still suppresses every other column's bounds on 26.3 as well (behind the BETA allow_insert_into_iceberg). Only the surrounding names differ.

That makes 26.3 an adaptation rather than a conflict resolution, so the call is the owner's and I will do either. If 26.3 is wanted, I will push a resolved cherrypick/26.3/112934 to my fork for someone with push access to apply: the filterWritableStatistics change with the two call sites renamed, no 04652 edits, and the new 04739 test only if it passes against a 26.3 build, which I have not measured. If it is not wanted, this can be closed like #119455.

26.7 (#121533), 26.8 (#121534) and 26.9 (#121535) already carry #112414 and need nothing from me.

One conflict, at the two call sites in `IcebergWrites.cpp`. The helper rename
and its all-or-nothing to per-field change merged on their own; only the
callers collided, because master reads `effective_statistics` (the per-file
statistics this branch does not have) where this branch reads
`data_file_statistics`, and master wraps the `if` bodies in braces where this
branch does not. Resolved to the branch's variable and brace style over the
new `filterWritableStatistics`.

`04652_iceberg_insert_per_file_statistics` does not exist on this branch, so
its half of the change is dropped. Nothing is lost: that hunk only re-baselines
an existing test's expectations and comments to the new per-field bounds, while
the coverage for the change itself is the new
`04739_iceberg_insert_partial_statistics_bounds`, which carries over unchanged.

Checked for the new test: `allow_insert_into_iceberg` and `USER_FILES_PATH` are
both here, and `canDumpIcebergStats` differs from master's only by the four
`Decimal*` cases, which the test does not exercise. No other test on this branch
asserts written Iceberg bounds, so the all-or-nothing to per-field flip cannot
break one silently.

The source resolution is byte-identical to the one on private release/26.4.

Upstream: #112934

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@robot-ch-test-poll2
robot-ch-test-poll2 merged commit a6811e7 into backport/26.3/112934 Sep 24, 2026
1 check passed
@robot-ch-test-poll2
robot-ch-test-poll2 deleted the cherrypick/26.3/112934 branch September 24, 2026 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants