Skip to content

Fix Iceberg _row_id pruning dropping rows of a rewritten file that has no row lineage statistics - #124591

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai-iceberg-row-lineage-missing-stats-pruning
Oct 10, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai-iceberg-row-lineage-missing-stats-pruning

Conversation

@groeneai

@groeneai groeneai commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Closes: #124271

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 a filter on the Iceberg v3 virtual columns _row_id or _last_updated_sequence_number returning no rows for a data file rewritten by copy-on-write, when the manifest has statistics for the table columns but not for the row lineage columns. Closes #124271.

Description

On 26.9 (v26.9.12.8-stable), SELECT id FROM icebergS3(...) WHERE _row_id = 1 returns no rows for a format-version 3 data file whose rows keep their row ids after a copy-on-write rewrite (so they lie below the file's first_row_id), when its manifest entry has statistics for the table columns but none for _row_id. The same happens for _last_updated_sequence_number.

addRowLineageHyperrectangles took "some column of the entry has column_sizes" as proof that a lineage column without statistics is absent from the file, and pruned on the inherited block [first_row_id, first_row_id + record_count - 1] ([sequence_number, sequence_number]). In the spec every metric map is optional and a missing id means unknown. The branch came with #115603.

The branch is removed. Without declared bounds a lineage column gets the existing fallback [0, top of the inherited block], already used for files without statistics: a materialized row id is below the table's next-row-id, so below first_row_id, and a copied _last_updated_sequence_number belongs to an earlier commit.

Cost: files written without lineage statistics (Spark and ClickHouse appends) lose the lower side of the range. Over five 10-row appends _row_id = 25 now skips 2 files instead of 4, and _last_updated_sequence_number = 2 skips 1 instead of 4. Filters above a value (_row_id >= X, the incremental _last_updated_sequence_number > N read) prune as before.

A new integration test strips only the lineage statistics from a Spark copy-on-write manifest: it fails without the fix ('' == '0') and passes with it. Seven count assertions that encoded the old lower bound now match the numbers test_pruning_without_column_statistics already asserts for the same fallback. The wrapped-block probe moved to _row_id >= 20, which still fails when the overflow guard is removed.

🤖 Generated with Claude Code


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

Version info

  • Merged into: 26.10.1.2047-master (included in 26.10 and later)

…ge statistics

`addRowLineageHyperrectangles` took "some column of the manifest entry has
`column_sizes`" as proof that a lineage column with no statistics is absent
from the data file, and pruned `_row_id` / `_last_updated_sequence_number`
on the inherited block `[first_row_id, first_row_id + record_count - 1]` /
`[sequence_number, sequence_number]`. The Iceberg spec makes every metric map
optional and a missing id means unknown, so a copy-on-write rewritten file
whose materialized values lie below that block was skipped and its rows lost
(ClickHouse#124271). The branch came with ClickHouse#115603.

Without declared bounds a lineage column now gets the existing fallback
`[0, top of the inherited block]`: a materialized row id is below the table's
`next-row-id` and a copied sequence number belongs to an earlier commit.

The new integration test strips only the lineage statistics from a Spark
copy-on-write manifest. Seven count assertions that encoded the old lower
bound are updated to the fallback numbers, and the wrapped-block probe moves
to `_row_id >= 20`, which still distinguishes the overflow guard.

Closes ClickHouse#124271

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-request PR origin: a maintainer pinged or directed groeneai labels Oct 8, 2026
@groeneai

groeneai commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 0 findings), plus my own cold review (1 nit).

# Sev Finding Verdict Evidence / action
1 💡 The description names the input shape (lineage statistics missing, other columns present) but no writer that produces it AGREE, noted Not blocking: the shape is valid per the spec (every metric map is optional, a missing id means unknown) and the test builds it from a real Spark copy-on-write manifest

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are
terminal per finding. Findings on hunks unchanged by the fix round are auto-dropped.

Session id: cron:clickhouse-review-slot-8:20261008-095400

@clickhouse-gh

clickhouse-gh Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [c2435ca]

Summary: ✅


AI Review

Summary

This PR removes an unsafe Iceberg v3 pruning shortcut for _row_id and _last_updated_sequence_number when a manifest entry has statistics for ordinary columns but omits lineage statistics. The read-side change is conservative and matches the contract described in the PR: when lineage bounds are missing, pruning now falls back to the safe range [0, inherited_upper] instead of assuming the inherited block is exact. The added regression test rewrites a real Spark copy-on-write manifest into the problematic shape and covers the rows-lost case from #124271; I did not find a remaining correctness issue in the current diff.

Final Verdict
  • Status: ✅ Approve

LLVM Coverage Report

Measured on commit c2435ca.

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: 14/14 (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
@clickhouse-gh clickhouse-gh Bot added the comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. label Oct 8, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing c2435caee with master a100fe05e (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, 13 s compile time in total, 7 of them have a recent master baseline.

Job report

@PedroTadim PedroTadim assigned PedroTadim and unassigned PedroTadim Oct 8, 2026
@PedroTadim

Copy link
Copy Markdown
Member

@SmitaRKulkarni @scanhex12 this is not my expertise to review

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@alexey-milovidov alexey-milovidov self-assigned this Oct 10, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 10, 2026
Merged via the queue into ClickHouse:master with commit 61038e4 Oct 10, 2026
152 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 10, 2026
zvonand added a commit to Altinity/ClickHouse that referenced this pull request Oct 25, 2026
Antalya 26.8 Backport of ClickHouse#124591 - Fix Iceberg `_row_id` pruning dropping rows of a rewritten file that has no row lineage statistics
@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

can be tested Allows running workflows for external contributors comp-iceberg Apache Iceberg tables: reading and writing Iceberg metadata (snapshots, manifests, schema evoluti... groeneai-origin-request PR origin: a maintainer pinged or directed groeneai pr-bugfix Pull request with bugfix, not backported by default 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.

Iceberg v3 _row_id pruning drops rows when manifest stats omit the lineage field

4 participants