Skip to content

Write per-file statistics into Iceberg manifest entries on INSERT - #112414

Merged
alexey-milovidov merged 6 commits into
ClickHouse:masterfrom
groeneai:fix-iceberg-compaction-per-file-stats
Aug 29, 2026
Merged

alexey-milovidov merged 6 commits into
ClickHouse:masterfrom
groeneai:fix-iceberg-compaction-per-file-stats

Conversation

@groeneai

@groeneai groeneai commented Jul 29, 2026 •

Copy link
Copy Markdown
Collaborator

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

Fixed Iceberg INSERT writing manifest-wide aggregate column statistics into every data_file entry when a partition produced more than one data file. Each entry's null_value_counts, column_sizes, lower_bounds and upper_bounds now describe only the data file it points at. Previously an entry could report more nulls than the file had rows, so a spec-conforming external reader pruned files that contained matching rows.

Description

MultipleFileWriter already computes per-file statistics in lockstep with the per-file row and byte counts. The INSERT sink passed only the manifest-wide aggregate, so generateManifestFile took its file-index-independent branch and stamped the same statistics onto every entry.

The written values are not merely imprecise, they are impossible and non-conservative. Inserting three rows as three one-row files, score non-NULL in the first only, made every entry report null_value_counts = 2 inside a 1-row file and inflated column_sizes threefold. The Iceberg rule null_count == record_count implies the column is all-NULL in that file, so an external reader evaluating score = 10 skipped all three files and returned no rows for data that was present. ClickHouse's own reader never prunes on null_value_counts, which is why ClickHouse-only round trips stayed correct and this went unnoticed.

The fix selects those per-file statistics inside the existing type-aware branch, via a new defaulted parameter the sink populates. No bound is widened and no check is loosened: the same serialization path runs, on true values instead of impossible ones. A size mismatch against the data files throws LOGICAL_ERROR rather than falling back to the aggregate, so a release build cannot silently publish mis-paired metadata.

Bounds become per-file too. They were never wrong before, only widened to the manifest union, so that part is an accuracy improvement rather than a correctness fix, and it is not uniformly a pruning improvement (see below). The Avro schema is unchanged, existing manifests are never rewritten, no setting is added, and all existing callers are byte-unchanged because the new parameter defaults to null.

value_counts is still not emitted; that is #103168 and out of scope. The compaction-side occurrences of this defect class are handled by #110069, which touches the same function, so whichever lands second needs a trivial rebase.

Bounds trade-off for entries whose column is all-NULL in one file

canWriteStatistics omits the whole bounds map for an entry as soon as one column's bound is not serializable. A column that is all-NULL inside one file yields an unserializable bound for that entry (ColumnNullable::getExtremes returns NULL extremes, which canDumpIcebergStats rejects), where the manifest-wide union still had a finite bound contributed by another file. Such an entry therefore ends up with no bounds at all instead of union bounds.

Omitted bounds are conservative, so no reader can be misled, but that entry loses bound-based pruning. The all-or-nothing granularity of canWriteStatistics is pre-existing and left alone here. The regression test asserts this behaviour explicitly, in both directions, so it is documented rather than rediscovered later.

Version info

  • Merged into: 26.9.1.337 (included in 26.9 and later)
  • Backported to: 26.8.3.94, 26.7.8.9, 26.6.6.17

groeneai and others added 3 commits July 28, 2026 15:12
An INSERT that produced more than one data file per partition wrote the
manifest-wide aggregate column statistics into every `data_file` entry of that
manifest, so `null_value_counts`, `column_sizes`, `lower_bounds` and
`upper_bounds` described the union of all files instead of the file the entry
points at.

The values were not merely imprecise but impossible and non-conservative: with
one row per data file, each one-row entry reported `null_value_counts = 2` for a
table holding two NULLs in total, and `column_sizes` were inflated by the file
count. The Iceberg pruning rule `null_count == record_count` implies the column
is all-NULL in that file, so an external reader evaluating `score = 10` or
`score IS NOT NULL` skipped every file and returned no rows for data that was
present. ClickHouse's own reader never prunes on `null_value_counts`, which is
why ClickHouse-only round trips stayed correct and this went unnoticed.

`MultipleFileWriter` already computed the correct per-file statistics and kept
them in lockstep with the per-file row and byte counts; the sink discarded them
and passed only `getResultStatistics`, so `generateManifestFile` fell into its
file-index-independent branch and stamped one set of values inside the per-file
loop. The fix is applied at that discard point: a defaulted per-file parameter
the sink populates, selected inside the existing type-aware branch. The same
serialization path runs, on true values rather than impossible ones.

A size mismatch between the per-file statistics and the data files throws
`LOGICAL_ERROR` rather than falling back to the aggregate, so a release build
cannot silently publish mis-paired metadata. A `chassert` would compile out.

Bounds become tighter, which is strictly more accurate and allows more pruning.
The Avro schema is unchanged, existing manifests are never rewritten, no setting
is added, and all existing callers are byte-unchanged because the new parameter
defaults to null. `value_counts` is still not emitted (ClickHouse#103168).

Co-Authored-By: Claude Fable 5 <[email protected]>
The pairing of per-file statistics to data files is a bare index, so a
permutation of the statistics relative to `data_file_names` would attach one
file's `null_value_counts` to another file's entry. That is the same
non-conservative metadata the fix removes: an entry can then report
`null_count == record_count` for a file that holds a matching row, and a
spec-conforming external reader prunes it.

Every assertion the test had was invariant under such a permutation. They were
sorted multisets over `(record_count, null_value_counts[k])`, a cross-table
`max(column_sizes)` inequality, or a read of the table data that was never
joined to any entry's `file_path`. Reversing the per-file vector left the
reference byte-identical.

Two scenarios now read the manifest at the Avro level and join each entry to
the Parquet file its `file_path` names. The first compares the entry's
`record_count` and `null_value_counts` against that file's real row and null
counts and emits a per-entry verdict ordered by the file's own `id`, so a
permutation moves the output. The second uses a table with no nullable column,
where every entry carries bounds, and requires each entry's decoded
`lower_bounds` and `upper_bounds` to equal the single row its own file holds.

Reversing the per-file vector now reddens only these two scenarios while every
pre-existing assertion stays byte-identical, which is what pins the pairing
contract rather than a multiset.

The scenarios also document the bounds behaviour in both directions. An entry
whose nullable column is entirely NULL legitimately carries no bounds at all,
because `canWriteStatistics` is all-or-nothing across an entry's columns and
`ColumnNullable::getExtremes` yields NULL extremes that `canDumpIcebergStats`
rejects. Writing per-file statistics therefore gains an upper bound on the
bounded file and drops the union's lower bound on the all-NULL ones.
Conservative in both directions, and now frozen in the reference rather than
rediscoverable as a regression.

Bounds are held as raw little-endian bytes, decoded here with
`reinterpretAsInt32`. No metadata is fabricated, both new tables are scoped to
the test database, and the test stays parallel-safe.

Co-Authored-By: Claude Fable 5 <[email protected]>
The pairing of per-file statistics to data files is a bare index that governs
all four statistics at once, and `column_sizes` is one of the values this change
makes describe a single data file. It was the only one no assertion could catch
a mis-pairing of.

Its one assertion compared the largest per-file size against the largest
whole-manifest size, which detects the aggregate fallback but constrains no
individual entry. The per-entry cross-checks projected `record_count`,
`null_value_counts` and the bounds, but not `column_sizes`. Both of their
fixtures also give every data file the same per-file sizes, four bytes for a
one-row `Int32` and five for a one-row `Nullable(Int32)`, so reversing the
per-file vector could not move a size value there.

A third scenario gives each data file a `String` of a different width, which
makes each entry's size distinct, and joins every entry to the Parquet file its
`file_path` names. Reversing the per-file vector now attaches the twelve-byte
file's twenty-byte size to the four-byte file's entry, and dropping the fix
restores the manifest-wide forty-eight bytes on all three entries, which is the
sum of the three per-file values.

The frozen counts are in-memory `IColumn::byteSize` sums rather than Parquet
file sizes, so they do not depend on the encoding, the compression codec or the
build flavour. For a one-row `String` the value is the character bytes plus one
offset, because `insertData` appends exactly the given length with no
terminator.

Co-Authored-By: Claude Fable 5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review (3 rounds, 13 findings, 7 AGREE / 0 DISAGREE on substance)

Every change below was reviewed by a second model independently of the author, and by a reviewer
that never edits the code. Findings are adjudicated with a verdict and evidence; nothing was
accepted or rejected on assertion alone. Both fix rounds were test-only: the source was accepted in
round 1 and frozen after it.

Round 1 (head 5cc6788723e3ea) - 5 findings, 5 AGREE

❌ stats-file-pairing (major, AGREED, fixed) - the statistics-to-file pairing is a bare
index, yet every assertion was a sorted multiset or an aggregate. Reversing the per-file vector left
the reference byte-identical while attaching the all-NULL file's statistics to the file holding
score = 10, re-creating exactly the unsafe pruning this change removes. Fixed by joining each
manifest entry to the Parquet file its file_path names and comparing against that file's real
contents.

⚠️ bounds-change-untested (major, AGREED, fixed) and bounds-omission-regression-undisclosed
(major, AGREED, fixed)
- the description claimed the new bounds "allow more pruning". Code reading
refutes the pruning half: canWriteStatistics is all-or-nothing across an entry's columns, and a
column that is all-NULL in one file yields NULL extremes that canDumpIcebergStats rejects, so such
an entry now emits no bounds where the manifest-wide union had a finite one. Conservative, never
wrong results, but a real trade-off that the description had not disclosed. The description was
corrected and the behaviour is now asserted in both directions rather than left to be rediscovered.

💡 Two nits (AGREED): the type matrix's drift from the plan is now documented (LowCardinality and
Decimal cannot exist in an Iceberg table at all - getIcebergType has no arm for either and its
default throws - so the planned assertion was unsatisfiable); a zero-row data file would get
present-but-empty maps instead of null, noted and deliberately not changed.

Round 2 (head 640c9d8df15157) - 4 findings, 2 AGREE, 2 dropped

❌ column-sizes-pairing (major, AGREED, fixed) - the round-1 cross-check projected
record_count, null_value_counts and both bounds, but not column_sizes, whose only assertion
was relational and constrained no individual entry. Both per-entry fixtures also made per-file
sizes identical (one row of fixed-width types each), so a column-size-only mis-pairing was
invisible. Since column_sizes is named in this change's own changelog entry, a third scenario
with a per-file-distinct-width column now asserts each entry's exact column_sizes against the
file it points at.

⚠️ PR description over the concision budget (major, AGREED, fixed) - condensed; the
canWriteStatistics bounds trade-off moved into a collapsed section.

💡 bounds-decode-endianness (nit, dropped) - the test decodes bounds with
reinterpretAsInt32 over bytes written by memcpy of a host Int32. Writer and reader share the
same byte order, so the assertion cannot false-fail. The writer's endianness assumption is
pre-existing and a separate concern. A second nit about the description's first line was dropped as
already correct.

Round 3 (head 8ee4fdfe5d9119) - clean, 4 self-raised nits all refuted

The independent second-model pass returned zero findings. The reviewer's own cold pass raised
four points and refuted all four against the source rather than waving them through:

💡 the frozen column_sizes byte counts are deterministic on every platform and build -
DataFileStatistics accumulates an in-memory IColumn::byteSize, IColumn::Offset is a fixed
UInt64, insertData appends exactly the string length with no terminator, and every reshaping
step in the insert path sizes the character array exactly, so no Parquet encoding, codec or block
size enters the values. Corroborated arithmetically: the aggregate the whole-fix mutation produces
is exactly the sum of the three frozen per-file values.
💡 the new fixture's non-key String column cannot interact with the sort-order rollover path,
because one row per data file is pinned independently.
💡 the Related: line for #110069 is inside the template's own comment block, but the rendered
description names that pull request in prose.
💡 the 04652 test number is now shared with a test that landed on master; the style check flags
only numbering gaps, never collisions, and both filenames are free.

Verified correct and not re-litigated

The manifest-entry statistics fields are written from exactly one place in the tree, so the fix site
is complete and no sibling path is owed a change. The per-file statistics objects are pushed in
lockstep with the per-file row and byte counts, so their alignment holds by construction; the guard
on that alignment is a real throw, not a chassert, so a release build cannot publish mis-paired
metadata, and it sits at the top of the manifest writer so it covers every present and future
caller. Each writer is finalized exactly once before the metadata-conflict retry loop, and the loop
never re-finalizes, so the vector and the pointers into it stay valid across all retries; a mis-pair
would throw into the existing cleanup path, which removes the written data files rather than
publishing them. The other three callers of the manifest writer are byte-unchanged and all take the
new parameter's null default, and the delete-manifest caller passes single-element lists so its
aggregate equals its per-file value by construction. The verbatim-bytes statistics channel is
untouched, which is why value_counts is still not emitted. No existing reference file moves: only
one other stateless test asserts Iceberg statistics and it writes a single data file per manifest,
and the integration tests assert map lengths or row counts, never per-entry values. An
INSERT ... SELECT is always executed synchronously, so the AsyncInsert lane cannot perturb the
one-row-per-file fixture.

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. tests/queries/0_stateless/04652_iceberg_insert_per_file_statistics.sh. iceberg_insert_max_rows_in_data_file = 1 plus pinned block sizes fix the data-file count at one row per file, so there is no dependence on randomized block sizes; 50/50 randomized runs pass.
b Root cause explained? Yes. MultipleFileWriter maintains both a manifest-wide and a per-file statistics accumulator, keeping the per-file objects in lockstep with the per-file row and byte counts. The INSERT sink passed only the aggregate, so generateManifestFile took its file-index-independent branch and stamped one set of values inside the per-file loop. Every entry therefore received the union of all files, and a per-file null_value_counts could exceed that file's record_count. Since the Iceberg rule null_count == record_count implies the column is all-NULL in that file, a spec-conforming external reader pruned files that contained matching rows.
c Fix matches root cause? Yes. The defect is a correct per-file value being discarded at the boundary, and the fix is applied at that discard point: the sink now passes the per-file statistics and the existing type-aware branch selects the entry's own object. No bound is widened, no check is loosened, no statistics are suppressed and no data-file count is forced. Clamping null_value_counts to record_count was rejected as a symptom guard: it would hide impossible metadata instead of writing correct metadata, and would leave column_sizes and bounds wrong.
d Test intent preserved / new tests added? Yes. No existing test was weakened or removed and no reference file moved. The test asserts no entry reports more nulls than its file has rows, pins the exact per-file (record_count, null_count) multiset, checks column_sizes are per-file rather than manifest-wide, and includes a single-data-file control, a round-trip control and a guard that value_counts stays unemitted. Because the statistics-to-file pairing is a bare index, three further scenarios read the manifest at the Avro level and cross-check every entry against the Parquet file it names: one compares the entry's record_count and null_value_counts with that file's real contents, one decodes lower_bounds/upper_bounds with reinterpretAsInt32 and requires each to equal its own file's single row, and one gives each file a String of a different width so that every entry's column_sizes is distinct and is checked against the file it names. Those three are what a permuted pairing cannot survive; the aggregate inequality alone constrained no individual entry, and the first two fixtures give every file identical sizes, so column_sizes needed its own fixture to become permutation-sensitive.
e Both directions demonstrated? Yes, on two independent binaries with verified distinct Build IDs and freshly started servers. Pre-fix (master snapshot, Build ID ef52c5f8…, both carrier files md5-identical to origin/master): FAIL, reporting null_value_counts = 2 inside each 1-row file, 3 impossible entries, paired=no on every entry and manifest-wide bounds on all three. With the fix (Build ID 3d036a49…): OK, (1,0),(1,1),(1,1), 0 impossible entries, paired=yes and bounds_are_own_row=yes throughout, and per-entry column_sizes of 12/16/20 bytes for the three files. Three mutations confirm the assertions are load-bearing. Reversing the per-file vector reddens only the three cross-checking scenarios while every other assertion stays byte-identical, which is what proves they pin the pairing contract rather than a multiset; that arm attaches the third file's 20-byte size to the first file's entry. Reverting the sink argument to null reproduces the pre-fix output exactly, including the manifest-wide column_sizes of 48 bytes on every entry, which is exactly the sum of the three per-file values. Making the alignment guard unsatisfiable aborts with the expected LOGICAL_ERROR. 50/50 randomized runs pass.
f Fix is general across code paths? Yes. generateManifestFile has exactly four call sites. The INSERT sink is the defect and is fixed. The manifest-only compaction rewrite already passes correct per-file statistics. The Mutations.cpp call site passes single-element lists, so the aggregate equals the per-file value by construction (verified by reading the call). The physical-rewrite metadata call site carries the same defect class and is deliberately left to #110069, which already fixes it, to avoid a duplicate change to the same lines. Delta Lake has an analogous row limit but its own writer and does not use generateManifestFile, so it is out of scope.
g Fix generalizes across inputs (params/datatypes/wrappers)? Yes. The test's type matrix covers Nullable(Int32), Nullable(String), Nullable(Int64), Nullable(Float64) and Nullable(Date), plus an all-NULL column whose bounds are omitted rather than throwing, and asserts no impossible entry for any of them. It also covers a partitioned table producing two data files in each of two partitions, so multiple manifests are exercised, and the single-data-file boundary is asserted to be unchanged. Two non-nullable tables are covered too, so the bounds path is exercised on every entry rather than only on the one entry a nullable fixture leaves bounded, and a variable-width non-nullable String gives each file a distinct size. Decimal and LowCardinality are unreachable by construction: getIcebergType has no arm for either and its default throws BAD_ARGUMENTS, so such a column cannot exist in an Iceberg table. The per-file objects flow through the same serializer as the aggregate did, so every type behaves as before.
h Backward compatible? Yes. No setting is added or changed, so no SettingsChangesHistory.cpp entry is required. There is no serialization format change: the manifest Avro schema is untouched and only the values written into existing fields become correct, so an older server reading a new manifest sees the same fields with more accurate values. Existing manifests are never rewritten, so there is no migration and no downgrade hazard. Every existing caller is byte-unchanged because the new parameter defaults to null.
i Invariants and contracts preserved? Yes. The invariant established is that every data_file manifest entry's statistics describe exactly that data file, and it is enforced by a LOGICAL_ERROR throw rather than an assertion so that a release build cannot silently publish mis-paired metadata. The alignment it checks is already guaranteed by the writer, which pushes the per-file statistics together with the per-file counts on the same rollover path. Error and early-return paths carry no risk: the cancel, release and clear paths never publish per-file statistics, and the sink does not reach generateManifestFile on those paths.

Session id: cron:clickhouse-impl-slot-46:20260729-074000

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @arsenmuk @hanfei1991 — could you review this? Iceberg INSERT stamped the manifest-wide aggregate statistics onto every data_file entry when a partition produced more than one data file, so an entry could report more nulls than its file has rows and a spec-conforming external reader pruned files that held matching rows; the sink now passes the per-file statistics the writer already computes.

@PedroTadim PedroTadim added the can be tested Allows running workflows for external contributors label Jul 29, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [3e915ae]

Summary: ✅


AI Review

Summary

This PR fixes the INSERT path for Iceberg manifests so each data_file entry receives its own statistics instead of the manifest-wide aggregate. I did not find a new correctness, safety, or performance issue in the current diff; the generateManifestFile contract stays consistent across the changed INSERT path and the existing rewrite callers, and the added stateless coverage exercises the pairing, bounds, and column_sizes cases this fix depends on.

Missing context / blind spots
  • ⚠️ The latest full CI matrix for commit 3e915aed4904c582f4ab0ad7f9ffc8a2a72797f6 was still running during this review, so only early jobs were available as evidence.
Final Verdict

✅ No new review findings.

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.60% 86.60% +0.00%
Functions 91.90% 91.90% +0.00%
Branches 78.80% 78.90% +0.10%

Changed lines: Changed C/C++ lines covered: 54/58 (93.10%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Jul 29, 2026
@Algunenano Algunenano added the comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. label Jul 29, 2026
@scanhex12 scanhex12 self-assigned this Jul 29, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.30% 86.40% +0.10%
Functions 91.90% 91.90% +0.00%
Branches 78.50% 78.50% +0.00%

Changed lines: Changed C/C++ lines covered: 53/57 (92.98%) · Uncovered code

Full report · Diff report

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 8ee4fdf

Every failure below has an owner: a fixing PR (ours 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
Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel) / 01666_merge_tree_max_query_limit the per-table concurrency throttle the test asserts is keyed on query id, and secondary parallel-replicas reads are sent without one, so the holder query competes against itself and the run reports Code: 202 Too many simultaneous queries on stderr (3 of 3 reruns) #112385 (merged). The tested build predates it: compare/5fcce5de34a3...8ee4fdfe5d91 reports behind_by: 788, so this head was built before the fix landed and a master merge will clear it

Session id: cron:our-pr-ci-monitor:20260731-160000

Master added `user_defined_snapshot_id` to `generateManifestFile` in the
middle of its parameter list (the compaction manifest-lineage work). The
INSERT sink passes the trailing optional arguments positionally, so after
merging master its `/*data_file_formats=*/{}` bound to the new parameter
and every later argument shifted by one, ending in a hard compile error:

    error: no matching function for call to 'generateManifestFile'
    note: no known conversion from 'std::nullptr_t' to
          'const std::vector<DataFileEntryLineage>' for 21st argument

The merge itself was textually clean, so this only appears at build time.
Pass the new parameter explicitly, matching the argument spelling the
Compaction.cpp and Mutations.cpp callers already use.

Verified on the merged tree: 04652 passes with the fix, and the nullptr
mutation of the per-file statistics argument still reproduces the original
defect (impossible_entries: 3, null_count 2 inside one-row files), so the
regression oracle remains load-bearing. Siblings 04203, 04201 and 04614
are green.
@groeneai

groeneai commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 3e915ae

Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens.

Check / test Reason Owner / fixing PR
Build (arm_release) / Post Hooks build-profile telemetry INSERT to the CI logs cluster; NON-GATING, the check itself concluded success #113409 (ours, merged)

No test-level failure on this head: every Stateless/Integration/Stress/Bugfix-validation job concluded success (0 running, Finish Workflow success). This is the first ledger covering this commit; the previous one covered 8ee4fdfe5d9119fea8be405e0694597179a198df.

Session id: cron:our-pr-ci-monitor:20260809-230000

@groeneai groeneai added the groeneai-origin-follow-up PR origin: groeneai's own out-of-scope finding during its PR work label Aug 19, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Dear @scanhex12, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself.

@alexey-milovidov alexey-milovidov self-assigned this Aug 29, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Aug 29, 2026
Merged via the queue into ClickHouse:master with commit 257b90c Aug 29, 2026
183 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 29, 2026
@clickgapai

Copy link
Copy Markdown
Contributor

@groeneai @alexey-milovidov — ClickGap found the following in this PR:

Close anything that's wrong or already addressed.

@groeneai

Copy link
Copy Markdown
Collaborator Author

Answered in #117116 (comment): the finding is real, it is the compaction half this PR deliberately left to #110069 (open), and that PR already implements the per-file statistics fix the issue suggests.

groeneai added a commit to groeneai/ClickHouse that referenced this pull request Aug 30, 2026
Resolves the conflict with ClickHouse#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.

ClickHouse#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]>
@scanhex12 scanhex12 added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Sep 11, 2026
@robot-clickhouse robot-clickhouse added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Sep 11, 2026
clickhouse-gh Bot pushed a commit that referenced this pull request Sep 11, 2026
clickhouse-gh Bot added a commit that referenced this pull request Sep 11, 2026
Backport #112414 to 26.8: Write per-file statistics into Iceberg manifest entries on INSERT
clickhouse-gh Bot pushed a commit that referenced this pull request Sep 13, 2026
clickhouse-gh Bot added a commit that referenced this pull request Sep 13, 2026
Backport #112414 to 26.7: Write per-file statistics into Iceberg manifest entries on INSERT
PedroTadim added a commit that referenced this pull request Sep 14, 2026
Cherry pick #112414 to 26.6: Write per-file statistics into Iceberg manifest entries on INSERT
robot-clickhouse added a commit that referenced this pull request Sep 14, 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 Sep 14, 2026
clickhouse-gh Bot added a commit that referenced this pull request Sep 14, 2026
Backport #112414 to 26.6: Write per-file statistics into Iceberg manifest entries on INSERT
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-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. groeneai-origin-follow-up PR origin: groeneai's own out-of-scope finding during its PR work 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.

8 participants