Repository navigation
Support Iceberg position deletes and deletion vectors on ORC and Avro data files - #130093
alexey-milovidov merged 13 commits into
Conversation
`NativeORCBlockInputFormat` attached no `ChunkInfoRowNumbers`, so `_row_number` was NULL for ORC files and every consumer of physical row numbers (Iceberg position deletes and deletion vectors, `_row_id`) could not work with ORC data files. The row number of a batch is not the count of rows delivered so far: `RowReader` skips row groups inside a stripe and whole stripes (search argument, stripe statistics, `skip_stripes`). `Reader::readTail` now records the first row of every stripe (prefix sums of the footer's `number_of_rows`, checked for overflow in the existing stripe validation loop), and `RowReader::next` remembers `stripe first row + current row in stripe` of the batch it fills. A batch never spans a skipped region (`computeBatchSize` stops at the next skipped row), so one offset per chunk is exact. The format attaches it only when `need_row_numbers` is set, like the Parquet and Vortex readers. Also remove the `USE_PARQUET || USE_VORTEX` guards around the `_row_number` and `_row_id` extraction in `VirtualColumnUtils`: `ChunkInfoRowNumbers` is declared in `IInputFormat.h` and is produced by ORC and every `IRowInputFormat`, so a build without Parquet and Vortex must not return NULL row numbers for them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reading an Iceberg table with position deletes or deletion vectors on ORC or Avro data files
failed with `NOT_IMPLEMENTED` ("Position deletes are only supported for data files of Parquet
format"), and a position delete file in ORC or Avro format (Spark and Flink write the delete
files in the table's write format) was rejected with `BAD_ARGUMENTS`.
The delete transforms only need `ChunkInfoRowNumbers` on every chunk of the data file. The
Avro reader (an `IRowInputFormat`) already attaches it, and the native ORC reader does since
the previous commit, so both checks now accept Parquet, ORC and Avro. Reading the delete files
themselves is format-agnostic, as for equality deletes.
ORC chunks now carry row numbers, which would make `_row_id` of Iceberg v3 ORC data files
derived from `first_row_id + position`. The stored row ids of ORC files are not read, so a
rewritten file would return wrong ids; keep `_row_id` NULL for ORC as before.
Closes ClickHouse#130001
Co-Authored-By: Claude Opus 5.5 <[email protected]>
`max_rows_to_read` is not checked for `file()` reads, so the test reads the `SelectedRows` profile event instead. 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; 1 finding) plus my own review (3 findings). No blocker or major; nothing changed for them.
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-11:20261108-064300 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-5:20261108-063400 |
|
cc @scanhex12 @al13n321, could you review this and add the |
|
Workflow [PR], commit [de90c8f] Summary: ✅
AI ReviewSummaryThe PR enables Iceberg position deletes and deletion vectors for ORC and Avro data files while retaining compaction restrictions. No unresolved blockers or majors found at Missing context / blind spots
Final VerdictStatus: ✅ Approve |
…files Compaction reads every data file with the current schema as the header. The Parquet reader resolves the columns by field id, but the ORC and Avro readers resolve them by name, so after a column rename compaction cannot read the renamed column from older ORC/Avro files. Before this PR, `addPositionDeleteFile` refused position deletes on non-Parquet data files, which also kept compaction away from such tables. Now that reads accept ORC and Avro, `getPlan` has to refuse them itself. Measured on a Spark ORC table with one position delete, after `ALTER TABLE t RENAME COLUMN name TO renamed_name`: `OPTIMIZE` returned success, removed the original ORC files and wrote Parquet files where `renamed_name` is NULL in every row. The Avro twin failed with `THERE_IS_NO_COLUMN`. With this check both are refused with `NOT_IMPLEMENTED` before anything is written, as on master. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units9 translation units recompiled, 26 s compile time in total, 9 of them have a recent master baseline. |
`NativeORCBlockInputFormat` attached no `ChunkInfoRowNumbers`, so `_row_number` was NULL for ORC files and every consumer of physical row numbers (Iceberg position deletes and deletion vectors, `_row_id`) could not work with ORC data files. The row number of a batch is not the count of rows delivered so far: `RowReader` skips row groups inside a stripe and whole stripes (search argument, stripe statistics, `skip_stripes`). `Reader::readTail` now records the first row of every stripe (prefix sums of the footer's `number_of_rows`, checked for overflow in the existing stripe validation loop), and `RowReader::next` remembers `stripe first row + current row in stripe` of the batch it fills. A batch never spans a skipped region (`computeBatchSize` stops at the next skipped row), so one offset per chunk is exact. The format attaches it only when `need_row_numbers` is set, like the Parquet and Vortex readers. Also remove the `USE_PARQUET || USE_VORTEX` guards around the `_row_number` and `_row_id` extraction in `VirtualColumnUtils`: `ChunkInfoRowNumbers` is declared in `IInputFormat.h` and is produced by ORC and every `IRowInputFormat`, so a build without Parquet and Vortex must not return NULL row numbers for them. The same change as the first commit of ClickHouse#130093 (ClickHouse#130001). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Every ORC file the other tests of this branch read has a single stripe, so the stripe prefix sums behind the ORC row numbers were not exercised: `row_numbers_multi_stripe.orc` has three stripes of 1500, 2500 and 6000 rows with a row index stride of 100, and 05570 checks `_row_number` with batches that do not align with stripes or row groups, and with a filter push-down that skips a whole stripe and most row groups of the others. 05570 and its fixture are taken byte-identically from ClickHouse#130093, which adds the same ORC row-number commit, so either merge order adds the same files. The 05614 echo prints the number of data files, so its label says so. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This PR kept `_row_id` of v3 ORC data files NULL, because the ORC reader did not read the stored row lineage columns, so deriving `first_row_id + _row_number` would have been wrong for rewritten files. ClickHouse#130140 (merged) reads the stored ORC lineage now, so that exclusion turned into a regression on master: inherited ORC row ids were NULL again, and test_row_lineage_of_orc_and_avro_data_files[s3-orc], test_row_id_pruning_is_skipped_for_orc[s3] and test_row_id_pruning_is_skipped_for_orc_clickhouse[s3] failed in the merge queue. Restore the master code in StorageObjectStorageSource::generate. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
The merge queue run failed in 3 row-lineage integration tests ( |
Compaction rewrites every data file of the table under the current schema, and the ORC and Avro readers resolve the columns by name. Before this PR the position delete reader accepted only Parquet delete files, so compaction of a table with ORC or Avro delete files failed before it committed anything. Now that reads accept them, such a table reached the rewrite whenever its ORC or Avro data files had no delete attached (newer than the deletes, or outside their bounds), because only attached data files are checked. After a column rename, `OPTIMIZE` then succeeded and rewrote those files without the renamed column's values. `getPlan` now also refuses a position delete file that is not Parquet, so compaction accepts the same tables as before this PR. The test writes, with Spark, a Parquet data file with an ORC or Avro position delete and a newer ORC data file, renames a column, and checks that `OPTIMIZE` is refused and the renamed column survives. The ORC data file is newer than the delete, because Spark's Avro delete files record no bounds. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…sition-deletes-orc-avro The native ORC reader row-number commit of this PR reached master via ClickHouse#130140; the conflict in `ORC/Reader.h` is resolved to master's version. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Merged master to resolve the conflict in |
|
🕵 Merged the latest master ( |
# Conflicts: # tests/integration/test_storage_iceberg_with_spark/test_optimize.py
|
🕵 Merged the latest master ( |
|
🕵 Merged the latest master ( |
|
🕵 Merged the latest master ( |
|
🕵 |
|
📊 Cloud Performance Report ✅ AI verdict: no significant changes detected. K_source=4 K_base=30 flagged=0/65 clickbench🟢 No significant changes tpch_adapted_1_official🟢 No significant changes Debug info
|
`CH Inc sync` failed in the flaky check of `05569_iceberg_position_deletes_orc_avro`: on the cloud build `OPTIMIZE` goes through a different code path, which starts the background compaction jobs of the table. `clickhouse-local` does not create the background executors unless a `MergeTree` table exists, so the shutdown of the table called a method on a null executor in `BackgroundJobsAssignee::finish` and UBSan reported it. The test already ignored the result of `OPTIMIZE` on the cloud build, so do not run it there at all. The check on the open-source build is unchanged. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
🕵 The test already ignored the result of Also merged the latest master ( |
… on ORC are supported now Position deletes against ORC data files were implemented in #130093 (#130001), so after merging `master` the test passes and the comment about the expected failure is stale. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Closes: #130001
Related: #130140
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Iceberg position deletes and deletion vectors are now applied to ORC and Avro data files (reading such tables failed with
NOT_IMPLEMENTED). Closes #130001.Description
Merge-on-read Iceberg tables written by Spark, Flink, Hive or Impala with
write.format.default=orc/avrocould not be read:Position deletes are only supported for data files of Parquet format in Iceberg, but got ORC(#130001). This was never supported, so the category isImprovement.The delete transforms only need
ChunkInfoRowNumbers(the file row number of each chunk) from the data file's reader. Avro (anIRowInputFormat) already attaches it, and the native ORC reader does since #130140, which carried this PR's first commit (with05570); after merging master, that part is no longer in this diff. This PR makes the two Parquet-only checks (data file, and the delete file itself, which Spark writes in the table format) accept Parquet, ORC and Avro.OPTIMIZEstill refuses ORC and Avro position delete files, and position deletes on ORC and Avro data files (tested): compaction rewrites ORC and Avro data files by column name under the current schema, losing renamed columns.Tests: the issue's Spark tables from ice-lens (unmodified, both bitmap modes, one row per chunk) and a Spark integration test for position deletes and v3 deletion vectors on ORC and Avro. The Doris Flink ORC tables of #130016 now give the Doris expected results.
Workflow [PR]
Sync PR [sync-upstream/pr/130093]
Version info
26.12.1.303-master(included in26.12and later)