Skip to content

Reject an Iceberg INSERT whose columns were dropped or renamed after planning - #125095

Closed
serxa wants to merge 4 commits into
masterfrom
iceberg-insert-schema-drift
Closed

serxa wants to merge 4 commits into
masterfrom
iceberg-insert-schema-drift

Conversation

@serxa

@serxa serxa commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

Related: #121821

#121821 lets an INSERT into an Iceberg table succeed when a column was added after the query was analysed. The opposite case, a column (or a nested field) dropped or renamed after analysis, leaves the written block with a field that the table's current schema does not contain. Only the Parquet writer detected this, through its recursive field id check. The ORC and Avro writers wrote such a field without an Iceberg field id, and the data file statistics fell back to the schema's field ids keyed by position, which do not match the written columns.

The recursive check (validateIcebergFieldIds) now lives next to ColumnMapper and runs in MultipleFileWriter for every format, so such an INSERT fails with the existing error that asks to retry it. A block that only lacks fields of the current schema is still accepted. The data file statistics take the written columns' field ids without a fallback.

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):

An INSERT into an Iceberg table in ORC or Avro format now fails with an error that asks to retry it when ALTER TABLE ... DROP COLUMN or RENAME COLUMN commits while the INSERT is running, instead of writing a data file whose columns do not match the table schema.


Workflow [PR]
Sync PR [sync-upstream/pr/125095]

serxa and others added 3 commits October 10, 2026 18:56
…planning

An `INSERT` analysed before a concurrent `ALTER TABLE ... DROP COLUMN` or `RENAME COLUMN` writes a block with a column that the table's current schema no longer has. The data file statistics then fell back to the schema's field ids, keyed by position, which do not match the written columns, and the column was written without a field id. Throw the same retryable "metadata changed" error that the commit already raises for a schema change, instead of falling back. A block that is narrower than the schema (a column added after planning) is still accepted.

Related: #121821

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [e0f61eb]

Summary: ❌

job_name test_name status info comment
Style check FAIL
cpp FAIL cidb
Finish Workflow FAIL
python3 ./ci/jobs/scripts/workflow_hooks/new_tests_check.py FAIL
Code Review DROPPED
Fast test (arm_darwin) DROPPED
Build (amd_debug) DROPPED
Build (amd_asan_ubsan) DROPPED
Build (amd_tsan) DROPPED
Build (amd_msan) DROPPED
Build (amd_binary) DROPPED
Build (arm_asan_ubsan) DROPPED

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Oct 10, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. label Oct 10, 2026
Only the `Parquet` writer checked that every field of the written block, including nested ones, has a field id in the schema being written. The `ORC` and `Avro` writers silently left a missing id unset. Move the recursive check (`validateIcebergFieldIds`) next to `ColumnMapper` and run it in `MultipleFileWriter` for every format, with the existing error that asks to retry the `INSERT`. The test now covers `Parquet`, `ORC` and `Avro`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@serxa serxa closed this Oct 10, 2026
@clickhouse-gh clickhouse-gh Bot added comp-iceberg Apache Iceberg tables: reading and writing Iceberg metadata (snapshots, manifests, schema evoluti... and removed comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-iceberg Apache Iceberg tables: reading and writing Iceberg metadata (snapshots, manifests, schema evoluti... pr-bugfix Pull request with bugfix, not backported by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant