Skip to content

Tolerate Iceberg v3 reserved row-lineage field ids in native Parquet reader - #107377

Merged
scanhex12 merged 5 commits into
ClickHouse:masterfrom
gregakinman:gm/iceberg-v3-reserved-field-ids
Jul 15, 2026
Merged

scanhex12 merged 5 commits into
ClickHouse:masterfrom
gregakinman:gm/iceberg-v3-reserved-field-ids

Conversation

@gregakinman

@gregakinman gregakinman commented Jun 13, 2026 •

Copy link
Copy Markdown
Contributor

Closes: #107343

The native (V3) Parquet reader raised ICEBERG_SPECIFICATION_VIOLATION when 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 as RewriteDataFiles) but that are not part of the table schema. SchemaConverter::useColumnMapperIfNeeded rejected any field_id missing 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.24 release and verified fixed on a local build; a stateless regression test (04337_iceberg_v3_row_lineage_reserved_field_id) writes a table via IcebergLocal, injects the reserved _row_id column 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's ICEBERG_SPECIFICATION_VIOLATION throw is already present before that merge, reproduces on 25.11.2.24, and was hit in production on 26.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):

  • 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 reading Iceberg v3 tables whose Parquet data files contain reserved row-lineage columns (such as _row_id); the native Parquet reader no longer raises ICEBERG_SPECIFICATION_VIOLATION for reserved field ids that are not part of the table schema.

Version info

  • Merged into: 26.7.1.980 (included in 26.7 and later)
  • Backported to: 26.6.3.29, 26.5.7.43, 26.3.18.25

…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]>
@gregakinman

Copy link
Copy Markdown
Contributor Author

@scanhex12 @mkmkme would one of you be able to take a look?

Small fix to the native V3 Parquet reader: SchemaConverter::useColumnMapperIfNeeded now tolerates Iceberg reserved-range field ids (>= 2147483447, e.g. the v3 row-lineage _row_id = 2147483540) instead of raising ICEBERG_SPECIFICATION_VIOLATION, so tables whose data files were written by an external Iceberg engine remain readable.

@scanhex12 — you own the Iceberg field-id mapping (ColumnMapper / SchemaProcessor); @mkmkme — you wrote useColumnMapperIfNeeded. Background, repro, and a note on why the automated bisect in #107343 is confounded (it lands on a writer-only change, but the reader defect predates it and affects 26.3/26.4) are on the issue. Thanks!

@scanhex12 scanhex12 self-assigned this Jun 14, 2026
@scanhex12 scanhex12 added the can be tested Allows running workflows for external contributors label Jun 14, 2026
@scanhex12
scanhex12 requested a review from Copilot June 14, 2026 14:44
@clickhouse-gh

clickhouse-gh Bot commented Jun 14, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [f3a2efd]

Summary: ❌

job_name test_name status info comment
Stress test (arm_release) FAIL
Received signal 6 (internal) (STID: 3721-41da) FAIL cidb

AI Review

Summary

This PR makes SchemaConverter::useColumnMapperIfNeeded tolerate unmapped Iceberg reserved metadata field ids above 2147483447 in Parquet files, while preserving the existing ICEBERG_SPECIFICATION_VIOLATION behavior for non-reserved unmapped user ids. The added stateless test covers the row-lineage _row_id case and the strict 2147483447 boundary. I did not find a code issue that needs an inline review comment.

Missing context / blind spots
  • ⚠️ Several GitHub checks were still pending when reviewed (Build (arm_tidy), Bugfix validation (functional tests), Fast test, and the aggregate PR check). Completion of those CI jobs would close the execution evidence gap; there is no local clickhouse binary or build directory in this checkout to run 04337_iceberg_v3_row_lineage_reserved_field_id manually.
Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Jun 14, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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::useColumnMapperIfNeeded to ignore unknown reserved-range Iceberg field_ids instead of throwing ICEBERG_SPECIFICATION_VIOLATION.
  • Add a stateless test that creates an IcebergLocal table, rewrites its Parquet data file to include _row_id with reserved field_id, and verifies reads still succeed.
  • Add the expected .reference output 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.

@gregakinman

Copy link
Copy Markdown
Contributor Author

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]>
@clickhouse-gh

clickhouse-gh Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.10% 85.10% +0.00%
Functions 92.30% 92.30% +0.00%
Branches 77.30% 77.30% +0.00%

Changed lines: Changed C/C++ lines covered by tests: 6/6 (100.00%) | Lost baseline coverage: none · Uncovered code

Full report · Diff report

@clickhouse-gh

clickhouse-gh Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

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.

@scanhex12
scanhex12 enabled auto-merge July 15, 2026 13:56
@scanhex12
scanhex12 added this pull request to the merge queue Jul 15, 2026
Merged via the queue into ClickHouse:master with commit 81f8ef5 Jul 15, 2026
164 of 166 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 Jul 15, 2026
@clickgapai

Copy link
Copy Markdown
Contributor

Hi — could this be a backport candidate for 26.6, 26.5, 26.4, 26.3 (LTS)? No backport label was found, and the affected code appears to exist in those branches based on a file/function presence check.

Affected code: SchemaConverter::useColumnMapperIfNeeded — core code present in all supported branches.

Why this might apply: The native (V3) Parquet reader and useColumnMapperIfNeeded were introduced on 2025-06-28 (commit 24f5417, 'Yet another parquet reader'), predating all supported release branches; the ICEBERG_SPECIFICATION_VIOLATION throw is present in each. The author verified the defect reproduces in production on 26.4.2.10 and on 25.11.2.24. No backport label is present, so the fix should be backported to the currently-maintained stable/LTS branches that ship the native reader (26.3-26.6).

Other supported branches (26.2, 26.1) are not affected — the changed code does not exist there.

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 pr-must-backport or a version label like v26.6-must-backport.

mkmkme added a commit to Altinity/ClickHouse that referenced this pull request Aug 11, 2026
Antalya 26.6 Backport of ClickHouse#107377 - Tolerate Iceberg v3 reserved row-lineage field ids in native Parquet reader
@scanhex12 scanhex12 self-assigned this Aug 12, 2026
@scanhex12 scanhex12 added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Aug 12, 2026
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Aug 12, 2026
scanhex12 added a commit that referenced this pull request Aug 12, 2026
Backport #107377 to 26.6: Tolerate Iceberg v3 reserved row-lineage field ids in native Parquet reader
scanhex12 added a commit that referenced this pull request Aug 12, 2026
Backport #107377 to 26.5: Tolerate Iceberg v3 reserved row-lineage field ids in native Parquet reader
scanhex12 added a commit that referenced this pull request Aug 12, 2026
Backport #107377 to 26.3: Tolerate Iceberg v3 reserved row-lineage field ids in native Parquet reader
UnamedRus pushed a commit to UnamedRus/ClickHouse that referenced this pull request Aug 12, 2026
…eserved-field-ids

Tolerate Iceberg v3 reserved row-lineage field ids in native Parquet reader
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Aug 22, 2026
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Aug 24, 2026
…lineage field ids in native Parquet reader
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Aug 24, 2026
…lineage field ids in native Parquet reader
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…eserved-field-ids

Tolerate Iceberg v3 reserved row-lineage field ids in native Parquet reader
VighneshPath pushed a commit to VighneshPath/ClickHouse that referenced this pull request Sep 16, 2026
…lineage field ids in native Parquet reader
@subkanthi subkanthi mentioned this pull request Sep 16, 2026
11 of 17 tasks
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 pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-bugfix Pull request with bugfix, not backported by default pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR 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.

ClickHouse Parquet reader incorrectly throws ICEBERG_SPECIFICATION_VIOLATION for v3 tables

7 participants