Skip to content

Iceberg manifest list partition summaries - #118796

Merged
scanhex12 merged 2 commits into
masterfrom
iceberg_manifest_list_partition_summaries
Sep 8, 2026
Merged

scanhex12 merged 2 commits into
masterfrom
iceberg_manifest_list_partition_summaries

Conversation

@scanhex12

@scanhex12 scanhex12 commented Sep 8, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Improvement

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

Write partition field summaries into the Iceberg manifest list


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

Version info

  • Merged into: 26.9.1.1006 (included in 26.9 and later)
  • Backported to: 26.8.4.4, 26.7.8.8, 26.6.8.5, 26.3.33.90

`INSERT`, `DELETE` and `UPDATE` on an Iceberg table left the `partitions`
field of every new manifest-list entry null, so a reader could not skip a
manifest by its partition and had to open all of them. Only the manifest
rewrite done by compaction filled that summary in.

Each manifest written by these paths holds exactly one partition tuple, so
its field summary is exact: `lower_bound` equals `upper_bound` per partition
field. The summary is now built from the same partition values and types
that go into `data_file.partition` of the manifest itself, and the code that
serializes it is shared with the compaction path instead of being nested in
it. Unpartitioned tables keep writing a null summary.
Replaces the stateless test with
`test_storage_iceberg_no_spark/test_writes_manifest_list_partition_summary.py`,
which reads the Avro metadata directly instead of going through the
ClickHouse Avro reader. That distinguishes a null `partitions` field from an
empty list, which the stateless variant could not, and it covers `s3` as well
as `local` storage and both format versions.

Each manifest-list entry is paired with the partition tuple stored in the
manifest it points at, so a summary attached to the wrong entry fails the
test. The unpartitioned case pins the field staying null, and the `DELETE`
case covers both the new position-delete manifest and the data manifests
carried forward from the parent snapshot.
@clickhouse-gh

clickhouse-gh Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [b259fa7]

Summary: ❌

job_name test_name status info comment
Stress test (arm_msan) FAIL
MemorySanitizer: use-of-uninitialized-value (STID: 0988-3545) FAIL cidb

AI Review

Summary

This PR factors the manifest-list partitions serializer out of the compaction-only path and reuses it for INSERT, DELETE, and UPDATE, with an integration test that reads the Avro metadata directly. The new wiring is correct for freshly written manifests, but it still leaves carried-forward manifests unsummarized on the normal upgrade path, so I cannot approve it as-is.

Findings

⚠️ Majors

  • [src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergWrites.cpp:773] generateManifestList still copies the parent snapshot's f_partitions field verbatim in the use_previous_snapshots branch. If a table already has manifest-list entries written before this fix, the first post-upgrade INSERT / DELETE / UPDATE keeps those carried-forward entries at partitions = null, so external Iceberg readers still cannot prune the old manifests by partition. Suggested fix: when copying a carried-forward entry whose f_partitions is null, recompute the summary from the referenced manifest instead of copying the null forward unchanged.
Tests
  • ⚠️ Add a regression that starts from a partitioned table whose parent manifest list predates this fix (or manually clears partitions in that parent list), then runs a post-upgrade INSERT or DELETE and verifies that the carried-forward entries in the new snapshot gain summaries.
Final Verdict

Changes requested.

LLVM Coverage Report

Measured on commit b259fa7.

Metric Baseline Current Δ
Lines 88.80% 88.80% +0.00%
Functions 91.80% 91.80% +0.00%
Branches 81.10% 81.20% +0.10%

Changed lines: Changed C/C++ lines covered: 91/94 (96.81%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added pr-improvement Pull request with some product improvements comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. labels Sep 8, 2026

/// Writes the `partitions` field summary of one manifest-list entry. Every manifest written here holds
/// exactly one partition tuple, so `lower_bound == upper_bound` per partition field; readers use these
/// bounds to skip whole manifests. Left null when no summaries are supplied (unpartitioned table).

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.

This only fixes manifest-list entries whose partition tuple is already present in entry_partition_summaries. On the use_previous_snapshots path below we still copy old_entry.field(f_partitions) verbatim, so the first post-upgrade INSERT / DELETE / UPDATE on a table written before this fix keeps all carried-forward manifests at partitions = null. External Iceberg readers still cannot prune those old manifests by partition, and the new DELETE test does not catch it because its parent snapshot is created by the fixed INSERT path. Please backfill f_partitions when copying a carried-forward entry whose summary is null, or add a regression that starts from a pre-fix manifest list.

@clickhouse-gh

clickhouse-gh Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing b259fa765 with master d6eead06e (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of f0310cf12; 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

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

Job report

@scanhex12
scanhex12 enabled auto-merge September 8, 2026 21:07
@scanhex12 scanhex12 self-assigned this Sep 8, 2026
@scanhex12
scanhex12 added this pull request to the merge queue Sep 8, 2026
Merged via the queue into master with commit a63831d Sep 8, 2026
172 of 174 checks passed
@scanhex12
scanhex12 deleted the iceberg_manifest_list_partition_summaries branch September 8, 2026 21:29
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 8, 2026
@clickgapai

Copy link
Copy Markdown
Contributor

@scanhex12 — ClickGap found the following in this PR:

Close anything that's wrong or already addressed.

@tiandiwonder

Copy link
Copy Markdown
Contributor

Added v26.3-must-backport — flagging the rationale here since this landed as a pr-improvement rather than a bug fix, and the backport case is stronger than that label suggests.

While investigating a support escalation on Iceberg scan performance, we hit this from the outside: a table written by ClickHouse 26.1–26.8 has partitions null on every manifest-list entry produced by INSERT/DELETE/UPDATE, and the Iceberg Java library's ManifestEvaluator then gives up on manifest-level pruning altogether:

// apache/iceberg api/src/main/java/org/apache/iceberg/expressions/ManifestEvaluator.java:86
private boolean eval(ManifestFile manifest) {
    this.stats = manifest.partitions();
    if (stats == null) {
        return ROWS_MIGHT_MATCH;
    }
    ...

Measured against a 98-manifest table on S3, zero-match predicate, cold cache:

table written by Trino GetObject calls
Trino (summaries exact) 2 — metadata.json + manifest list only
ClickHouse (summaries null) falls back to opening every manifest

So the effect is not confined to ClickHouse's own scan planning — it degrades any downstream engine reading a ClickHouse-written Iceberg table (Spark, Trino, PyIceberg).

Two reasons this is worth backporting rather than leaving to the next major:

  1. It is baked into data already on object storage. The summary is fixed at write time, so a table written by an affected version keeps null summaries even after the cluster upgrades — only a rewrite_manifests can repair it. The longer the fix is master-only, the more unprunable metadata accumulates in customers' warehouses.
  2. The change is contained — IcebergWrites.cpp + Mutations.cpp, with an integration test (035137_iceberg_manifest_list_partition_summary.sh) already in the PR.

Verified as not present on any release branch:

$ for b in 26.8 26.7 26.6 26.5 26.4 26.3 26.2 26.1; do
    git merge-base --is-ancestor 5119ff7512e origin/$b && echo "$b: IN" || echo "$b: not in"
  done
26.8: not in   26.7: not in   26.6: not in   26.5: not in
26.4: not in   26.3: not in   26.2: not in   26.1: not in

Note 26.7/26.8 do reference f_partitions twice, but both sites are on the manifest rewrite/compaction path (one recomputing the summary so bounds survive a rewrite, one carrying it forward from the old entry) — the plain INSERT path writes null on every released branch.

Tagged v26.3-must-backport (oldest currently supported version per SECURITY.md: 26.8, 26.7, 26.6, 26.3). Please retag if a narrower range is preferred.

Context: https://github.com/ClickHouse/support-escalation/issues/8638

@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Sep 10, 2026
clickhouse-gh Bot added a commit that referenced this pull request Sep 13, 2026
Backport #118796 to 26.8: Iceberg manifest list partition summaries
clickhouse-gh Bot added a commit that referenced this pull request Sep 13, 2026
Backport #118796 to 26.7: Iceberg manifest list partition summaries
PedroTadim added a commit that referenced this pull request Sep 14, 2026
Cherry pick #118796 to 26.3: Iceberg manifest list partition summaries
PedroTadim added a commit that referenced this pull request Sep 14, 2026
Cherry pick #118796 to 26.6: Iceberg manifest list partition summaries
@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
strtgbb pushed a commit to Altinity/ClickHouse that referenced this pull request Sep 14, 2026
PedroTadim added a commit that referenced this pull request Sep 15, 2026
Backport #118796 to 26.3: Iceberg manifest list partition summaries
clickhouse-gh Bot added a commit that referenced this pull request Sep 15, 2026
Backport #118796 to 26.6: Iceberg manifest list partition summaries
@clickhouse-gh clickhouse-gh Bot added comp-iceberg Apache Iceberg tables: reading and writing Iceberg metadata (snapshots, manifests, schema evoluti... and removed comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-iceberg Apache Iceberg tables: reading and writing Iceberg metadata (snapshots, manifests, schema evoluti... pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-improvement Pull request with some product improvements 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 v26.3-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants