Repository navigation
Fix Iceberg _row_id and _last_updated_sequence_number filters losing rows of files that store lineage values - #130100
Conversation
A row's `_row_id` is the value stored in the data file, or `first_row_id` plus its position where the file stores NULL; `_last_updated_sequence_number` falls back to the data sequence number the same way. The manifest-level pruning used the declared bounds of a lineage column only when the column has no nulls, and otherwise the range `[0, first_row_id + record_count - 1]` (`[0, sequence number]`), which assumes a stored value is below the inherited block. Files that store values above it (compaction or copy-on-write keeping row ids, or other writers) were skipped and their rows lost: `WHERE _row_id > 1000` on the parquetry `iceberg-row-lineage/materialized` table returned nothing instead of ids 6 and 8, and the DuckDB `row_lineage_stored_columns` table (no statistics at all) lost the rows with stored `_row_id` 100/103 and sequence numbers 7/9. A file is now pruned by a lineage column only when its manifest declares bounds for it; when some rows may store NULL the range is the hull of the declared bounds and the inherited range. Without declared bounds (absent, undecodable or inverted) the file is not pruned by that column. The early returns for a missing `first_row_id`, an empty file, a negative sequence number and a block that does not fit in UInt64 stay as they were. The new test vendors both tables unmodified, at the paths used by ClickHouse#130017 and ClickHouse#130010. Closes ClickHouse#130022 Co-Authored-By: Claude Opus 5.5 <[email protected]>
`getFormatFilter` kept the conjuncts on `_row_id` and `_last_updated_sequence_number` for Iceberg, so the Parquet reader pruned row groups, pages and dictionaries by the statistics of the column stored in the data file. Those statistics do not cover rows that store NULL and inherit the value, so a filter above the stored maximum skipped row groups with matching inherited values. After a Spark copy-on-write `UPDATE` the rewritten file stores `_last_updated_sequence_number` [1, NULL, 1, 1], and `WHERE _last_updated_sequence_number = 2` lost the updated row with the default `input_format_parquet_filter_push_down = 1`. The lineage columns are now treated like every other virtual column added after the format; the filter is still applied after the source, and the manifest-level pruning keeps skipping whole files where declared bounds allow it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Files without lineage statistics (Spark and ClickHouse appends, Avro and ORC data files, a rewritten file whose lineage statistics were dropped) are no longer pruned by `_row_id` or `_last_updated_sequence_number`, so their expected pruned-file counts become 0 and the `read_rows` assertion that pinned the old skip is removed. New assertions on the Spark copy-on-write table: the declared bounds [1, 1] widened by the inherited sequence number 2 still skip the file for `_last_updated_sequence_number > 2`, and `= 2` / `> 1` return the updated row with Parquet filter push-down enabled. The wrapped-block test now also declares `_row_id` bounds [0, 0] with a null for the file whose block does not fit, so that widening by the wrapped block ([0, 8]) would skip it; this keeps the overflow guard observable now that a file without declared bounds is not pruned anyway. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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 (3 nits, no code change needed).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-9:20261108-075700 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-5:20261108-064300 |
|
Workflow [PR], commit [9f71dc4] Summary: ✅
AI ReviewSummaryReviewed PR #130100 at Missing context / blind spots
Final Verdict✅ Approve — no actionable code findings. Normal CI validation remains required. |
|
cc @scanhex12 @alesapin, could you review this and add the |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units131 translation units recompiled, 1281 s compile time in total, 131 of them have a recent master baseline. |
39da336
Closes: #130022
Related: #130017
Related: #130010
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed filters on the
Icebergv3 virtual columns_row_idand_last_updated_sequence_numbermissing rows of data files that store some of these values instead of inheriting them fromfirst_row_idand the data sequence number, for example a file rewritten by a copy-on-writeUPDATE. Closes #130022.Description
On
v26.10.2.103-stable,SELECT id FROM icebergLocal('iceberg-row-lineage/materialized') WHERE _row_id > 1000returns nothing for the parquetry table of #130022, whose second file stores_row_id1001 and 1003; withuse_iceberg_partition_pruning = 0it returns6,8.Two layers pruned by a range covering only one source of the values:
addRowLineageHyperrectanglesused the declared bounds only when the column has no nulls, otherwise[0, first_row_id + record_count - 1].getFormatFilterkept the lineage conjuncts in the filter pushed into the format, so Parquet skipped row groups by the statistics of the stored column, which do not cover inherited (NULL) values: after a Spark copy-on-writeUPDATE,WHERE _last_updated_sequence_number = 2lost the updated row with the defaultinput_format_parquet_filter_push_down = 1.Now a file is pruned by a lineage column only when its manifest declares bounds for it, widened by the inherited range when some rows may store NULL, and the format does not prune by lineage columns.
Cost: files without lineage statistics (every file appended by Spark or ClickHouse) are no longer skipped by these filters, e.g. by an incremental
_last_updated_sequence_number > Nread; files declaring lineage bounds still are. The old range covers what a spec-conforming writer stores, but the tables of #130022 and #130010 store values above it; keeping it for files without statistics still loses rows of the DuckDB tablerow_lineage_stored_columns, which declares none.Validation: the new test
05612_iceberg_row_lineage_stored_values_pruning(tables byte-identical to #130017 / #130010) fails on master and passes 50/50;test_row_lineage_pruning.pyfollows the new rule and gains a Parquet push-down assertion.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/130100]
Version info
26.11.1.1688-master(included in26.11and later)