Repository navigation
Add virtual columns from v3 spec for CDC pipelines - #115603
Conversation
|
Workflow [PR], commit [b7ebe59] Summary: ❌
AI ReviewSummaryThis PR threads Iceberg v3 row-lineage metadata ( PR Metadata
Findings
Tests
Final Verdict❌ Changes requested. LLVM Coverage ReportMeasured on commit b7ebe59.
Changed lines: Changed C/C++ lines covered: 383/389 (98.46%) · Uncovered code |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Object file sizes39 object files changed (+82.38 KiB total), 0 added.
835 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units344 translation units recompiled, 3096 s compile time in total, 344 of them have a recent master baseline. |
| for (size_t row_index = 0; row_index < total_rows; ++row_index) | ||
| { | ||
| const auto parsed_entry = manifest_file_deserializer->getParsedManifestFileEntry(row_index); | ||
| if (parsed_entry->content_type != FileContentType::DATA || parsed_entry->status != ManifestEntryStatus::ADDED |
There was a problem hiding this comment.
Iceberg v3 first_row_id inheritance is not limited to ADDED data files. The important case is the first commit after upgrading a table from v2 to v3: the carried-forward files are written as EXISTING entries with first_row_id = null, and the reader is supposed to assign them from the manifest's first_row_id plus the preceding record_counts.
Because this loop skips every EXISTING entry, those live files keep entry->first_row_id == null, so both _row_id and _last_updated_sequence_number come back NULL for all pre-upgrade rows and row-lineage pruning never fires on them. The inheritance pass needs to cover any live DATA entry with a null parsed_first_row_id, regardless of status.
| { | ||
| std::vector<UInt64> row_positions; | ||
| #if USE_PARQUET | ||
| if (auto chunk_info = chunk.getChunkInfos().get<ChunkInfoRowNumbers>(); chunk_info && virtual_values.first_row_id) |
There was a problem hiding this comment.
This makes _row_id silently Parquet-only. For a v3 Iceberg table written as ORC/Avro, first_row_id is still available from the manifest, but no non-Parquet reader attaches ChunkInfoRowNumbers, so row_positions stays empty here. Since materialized_row_ids are only requested for Parquet, the code falls into the default-null branch below and returns _row_id = NULL for every row.
If row-lineage virtual columns are meant to work only for Parquet, the read path should reject them explicitly for other Iceberg file formats; otherwise this needs a non-Parquet implementation and coverage instead of a silent null result.
There was a problem hiding this comment.
For a v3 Iceberg table written as ORC/Avro
Useless case
| return; | ||
| } | ||
|
|
||
| if (entry.first_row_id.has_value()) |
There was a problem hiding this comment.
This fallback is only safe for append-only files. A copy-on-write v3 file can still carry materialized _row_id / _last_updated_sequence_number values that diverge from the contiguous [first_row_id, first_row_id + record_count) block, and the manifest does not guarantee min/max stats for those reserved fields.
If the writer emits ordinary column stats but omits row-lineage stats, has_materialized_row_lineage stays false and this branch prunes on the bogus file-level range, which drops live rows. A concrete case is the rewritten file from test_materialized_row_ids_are_not_pruned_away: the file keeps row ids 0..3, the manifest advertises first_row_id = 4, and WHERE _row_id = 1 would incorrectly prune the file if only non-lineage stats are present.
The safe fallback here is "do not prune by row lineage" unless the manifest proves the reserved row-lineage columns are absent or provides usable bounds for them.
There was a problem hiding this comment.
I think this comment makes sense
| // always zero in case of format version 1 | ||
| const Int64 inherited_sequence_number; | ||
| const Int64 inherited_snapshot_id; | ||
| const std::optional<UInt64> inherited_first_row_id; |
There was a problem hiding this comment.
inherited_first_row_id -> maybe I missed it, where is this used ?
There was a problem hiding this comment.
Yes, it's maybe strange to have both inherited_first_row_id and inherited_first_row_ids. I'll replace with one lazy-materialised vector
| std::map<Int32, Int64> column_sizes; | ||
| std::map<Int32, Int64> value_counts; | ||
| std::vector<Int32> equality_ids; | ||
| std::optional<UInt64> first_row_id; |
There was a problem hiding this comment.
For this one, we need to add Column right
you dont want to add that is it ?
Then this variable is not needed then ?
Antalya 26.6 - Backport of ClickHouse#115603 - read row_lineage(iceberg v3) fields as virtual columns
…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]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Iceberg v3 has two new fields in manifest file - first_row_id and last_seq_num. This PR allows to read them as virtual columns
Workflow [PR]
Sync PR [sync-upstream/pr/115603]