Repository navigation
Tolerate Iceberg v3 reserved row-lineage field ids in native Parquet reader - #107377
Conversation
…reader `SchemaConverter::useColumnMapperIfNeeded` threw `ICEBERG_SPECIFICATION_VIOLATION` for any Parquet `field_id` absent from the Iceberg column mapper. Iceberg v3 data files written by Spark/Trino/Iceberg-Java (e.g. after a `RewriteDataFiles` compaction) physically contain reserved row-lineage columns such as `_row_id` (field_id 2147483540) and `_last_updated_sequence_number` (2147483539), which are not part of the table schema. The Iceberg spec reserves field ids >= 2147483447 (`Integer.MAX_VALUE - 200`) and requires readers to ignore unrecognized reserved ids; ClickHouse instead aborted the whole read. Skip unmapped field ids in the reserved range by returning the physical column name, so the existing unrequested-column path ignores them. Non-reserved missing field ids still raise the exception. The column mapper is built per data file from its own write-time schema, so dropped/evolved user columns are unaffected. Closes: ClickHouse#107343 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Refer to "spec-compliant Iceberg writer(s)" instead of Spark in the fix comment and the test comment. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
@scanhex12 @mkmkme would one of you be able to take a look? Small fix to the native V3 Parquet reader: @scanhex12 — you own the Iceberg field-id mapping ( |
|
Workflow [PR], commit [f3a2efd] Summary: ❌
AI ReviewSummaryThis PR makes Missing context / blind spots
Final VerdictStatus: ✅ Approve |
There was a problem hiding this comment.
Pull request overview
This PR fixes ClickHouse’s native (V3) Parquet reader for Iceberg v3 tables by tolerating reserved Iceberg metadata field ids (e.g. row-lineage _row_id) that can physically exist in Parquet files but are not present in the Iceberg table schema, and adds a stateless regression test that reproduces the issue by injecting such a reserved column into a data file.
Changes:
- Update Parquet
SchemaConverter::useColumnMapperIfNeededto ignore unknown reserved-range Icebergfield_ids instead of throwingICEBERG_SPECIFICATION_VIOLATION. - Add a stateless test that creates an IcebergLocal table, rewrites its Parquet data file to include
_row_idwith reservedfield_id, and verifies reads still succeed. - Add the expected
.referenceoutput for the new test.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/Processors/Formats/Impl/Parquet/SchemaConverter.cpp |
Skip unmapped Iceberg reserved-range field_ids by returning the physical column name instead of throwing. |
tests/queries/0_stateless/04337_iceberg_v3_row_lineage_reserved_field_id.sh |
New stateless regression test that injects reserved _row_id into a Parquet data file and verifies reads succeed. |
tests/queries/0_stateless/04337_iceberg_v3_row_lineage_reserved_field_id.reference |
Expected output for the new regression test. |
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Thank you for the approval @scanhex12! Addressed your comment |
…7483447 The spec allows tables to use field ids up to and including 2147483447 (Integer.MAX_VALUE - 200); only ids strictly greater are reserved. The previous `>= 2147483447` check would have silently accepted an unmapped column with field_id == 2147483447 (a genuine schema mismatch). Use a strict `>` check and add a regression case asserting that field id 2147483447 still raises ICEBERG_SPECIFICATION_VIOLATION. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Match the strict boundary used by the implementation and the negative case. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 6/6 (100.00%) | Lost baseline coverage: none · Uncovered code |
|
Dear @scanhex12, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself. |
81f8ef5
|
Hi — could this be a backport candidate for Affected code: Why this might apply: The native (V3) Parquet reader and Other supported branches ( Caveat: I verified that the modified code exists in those branches, but not whether the bug is actually reachable there — a new caller in master may be what makes this newly observable. If older branches can't reach the affected path, please ignore this; otherwise consider |
Antalya 26.6 Backport of ClickHouse#107377 - Tolerate Iceberg v3 reserved row-lineage field ids in native Parquet reader
Backport #107377 to 26.6: Tolerate Iceberg v3 reserved row-lineage field ids in native Parquet reader
Backport #107377 to 26.5: Tolerate Iceberg v3 reserved row-lineage field ids in native Parquet reader
Backport #107377 to 26.3: Tolerate Iceberg v3 reserved row-lineage field ids in native Parquet reader
…eserved-field-ids Tolerate Iceberg v3 reserved row-lineage field ids in native Parquet reader
…lineage field ids in native Parquet reader
…lineage field ids in native Parquet reader
…eserved-field-ids Tolerate Iceberg v3 reserved row-lineage field ids in native Parquet reader
…lineage field ids in native Parquet reader
Closes: #107343
The native (V3) Parquet reader raised
ICEBERG_SPECIFICATION_VIOLATIONwhen reading an Iceberg v3 table whose data files physically contain reserved row-lineage columns —_row_id(field id 2147483540) and_last_updated_sequence_number(2147483539) — that spec-compliant Iceberg writers emit (e.g. when tracking row lineage, or during compaction maintenance such asRewriteDataFiles) but that are not part of the table schema.SchemaConverter::useColumnMapperIfNeededrejected anyfield_idmissing from the Iceberg column mapper, so the whole read failed even though these columns are never requested. Spec-compliant Iceberg readers handle such files without issue.The Iceberg spec reserves field ids
> 2147483447(Integer.MAX_VALUE - 200) for metadata columns and requires readers to ignore unrecognized reserved ids: https://iceberg.apache.org/spec/#reserved-field-ids. This change skips unmapped field ids in that reserved range (returning the physical column name, so the existing unrequested-column path ignores them) instead of throwing. Non-reserved missing field ids still raise the exception. The column mapper is built per data file from its own write-time schema, so dropped or evolved user columns are unaffected.Reproduced on the
25.11.2.24release and verified fixed on a local build; a stateless regression test (04337_iceberg_v3_row_lineage_reserved_field_id) writes a table viaIcebergLocal, injects the reserved_row_idcolumn into the data file, and reads it back.Affected versions / backport: this reader defect predates #102362 (the commit the automated triage on #107343 bisected to). #102362 only changed ClickHouse's writer to emit
field_ids starting in 26.5; the reader'sICEBERG_SPECIFICATION_VIOLATIONthrow is already present before that merge, reproduces on25.11.2.24, and was hit in production on26.4.2.10. It therefore affects 26.3 and 26.4 and should be backported there. (The issue's automated repro marks 26.3/26.4 "clean" only because it relies on ClickHouse's own writer emitting field ids; the real-world trigger is an external Iceberg writer.)Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed reading Iceberg v3 tables whose Parquet data files contain reserved row-lineage columns (such as
_row_id); the native Parquet reader no longer raisesICEBERG_SPECIFICATION_VIOLATIONfor reserved field ids that are not part of the table schema.Version info
26.7.1.980(included in26.7and later)26.6.3.29,26.5.7.43,26.3.18.25