Repository navigation
Reject an Iceberg INSERT that writes a column the table no longer has, for every format - #126768
Conversation
…, for every format
An INSERT into an ORC or Avro Iceberg table whose block structure predates
an ALTER TABLE ... DROP COLUMN (a concurrent ALTER, or a table attached with
iceberg_metadata_file_path to the older metadata) aborted the process with a
libc++ hardening out-of-bounds assertion in DataFileStatistics::getNullCounts.
At equal width (DROP + ADD, RENAME) it committed a data file whose statistics
carried the wrong field ids, so manifest pruning returned wrong results.
The writer takes its field ids from the latest schema, while the block comes
from the older one. Only the Parquet writer refused a column without a field
id (validateIcebergFieldIds in convertSchema). For ORC and Avro
fieldIdsOfWrittenColumns returned {} and the DataFileStatistics constructor
fell back to schema-positional ids: past the end for a wider block, naming the
wrong columns at equal width.
Move validateIcebergFieldIds unchanged from the Parquet writer to
Formats/FormatFilterInfo (the Parquet directory is built only with USE_PARQUET,
the Iceberg writer with USE_AVRO) and call it in fieldIdsOfWrittenColumns for
every written column, so the first MultipleFileWriter constructor throws
INCORRECT_DATA before any data file exists. DataFileStatistics now takes only
the written columns' ids; the positional fallback and the unused
MultipleFileWriter::schema member are gone. Parquet keeps the same check and
message. Drop the now unused INCORRECT_DATA error code from PrepareForWrite.cpp.
Closes ClickHouse#125361
Co-Authored-By: Claude Opus 5.5 <[email protected]>
validateIcebergFieldIds: state the Nullable/LowCardinality naming rule in one line without citing Parquet-local helpers; drop the recursion narration. 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; 3 findings in the full pass, 0 in the delta recheck after one fix round) plus my own review.
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-8:20261019-180600 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-40:20261019-175500 |
|
cc @SmitaRKulkarni, could you review this and add the |
|
Workflow [PR], commit [7f6861e] Summary: ✅
AI ReviewSummaryThe PR rejects stale Missing context / blind spots
Final VerdictStatus: ✅ Approve. |
Requested in review (ClickHouse#126768): the stateless 05407 test was hard to read. The same cases now live in test_storage_iceberg_no_spark as one pytest per schema change (DROP COLUMN, DROP + ADD COLUMN, RENAME COLUMN, nested field rename, each for Parquet, ORC and Avro, plus the ADD COLUMN positive control), using the iceberg_utils helpers and the same pinned-metadata technique as test_remove_orphan_files_ignores_pinned_metadata. The ADD COLUMN control excludes Avro: there the stale INSERT is accepted (also on master) but every later SELECT fails with "Field d not found in Avro schema", which this change does not touch. Measured: fix binary 42/42 (14 cases x 3). Master 94e0f5a: 13 of 14 cases fail (ORC/Avro DROP COLUMN abort the server, ORC/Avro DROP + ADD, RENAME and nested rename are accepted, every Parquet refusal leaves a data file), the two ADD COLUMN controls pass. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The RENAME COLUMN block relied on a stale INSERT that writes the renamed column without a field id. ClickHouse#126768 refuses that INSERT for every format, so the block would start failing as soon as it is merged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI finish ledger - 838446aEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
CIDB has no other Session id: cron:our-pr-ci-monitor:20261021-090014 |
…dropped-renamed-column-all-formats # Conflicts: # src/Processors/Formats/Impl/Parquet/PrepareForWrite.cpp
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units156 translation units recompiled, 1546 s compile time in total, 156 of them have a recent master baseline. |
Closes: #125361
Related: #121821
Related: #125095
Related: #109838
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed an
INSERTinto anORCorAvroIcebergtable terminating the server, or committing a data file with wrong or missing field ids so that later queries returned wrong results, when a column theINSERTwrites was dropped or renamed away while it was running. Such anINSERTis now rejected withINCORRECT_DATA, as it already was forParquet.Description
On 26.9.19.9, an
INSERTinto anORCorAvroIcebergtable whose structure predates anALTER TABLE ... DROP COLUMN(a concurrentALTER, or a table attached withiceberg_metadata_file_pathto the older metadata) aborts the process inDataFileStatistics::getNullCounts. AfterDROP COLUMN+ADD COLUMNit commits statistics under shifted field ids, soWHERE d IS NULLreturns 3 of 6 rows; afterRENAME COLUMNit writes the column without a field id.Parquetalready refuses. The script in #125361 is the failing input.Root cause. Only the
Parquetwriter checked that every written column has a field id in the schema being written. ForORC/Avrothe writer found no id, andDataFileStatisticsfell back to schema-positional ids: past the end for a wider block, shifted afterDROP+ADD.Change.
validateIcebergFieldIdsmoves from theParquetwriter toFormats/FormatFilterInfo, and the Iceberg writer calls it for every format before the first data file is created.DataFileStatisticstakes the written columns' ids only, with no fallback.Parquetbehaviour is unchanged; mutations areParquet-only; experimental compaction is unchanged. #109838 adds an independent, earlier check. #125095 (closed) had the same change. A rename that keeps every written name present (two columns swapping names) still binds by name, as on master for every format.Validation.
test_storage_iceberg_no_spark/test_writes_stale_insert_after_alter.pycoversDROP COLUMN,DROP+ADD,RENAMEand a nested-field rename, each forParquet,ORCandAvro. It assertsINCORRECT_DATA, that a refusedINSERTleaves the table's files unchanged, and that a pinnedINSERTafterADD COLUMNis still accepted (Parquet,ORC). On master (1d607cb1acf3) 8 of its 14 cases fail: theORC/AvroDROP COLUMNcases abort the server and the otherORC/Avrocases are accepted; theParquetcases pass. Here all 14 pass.Workflow [PR]
Sync PR [sync-upstream/pr/126768]
Version info
26.11.1.2256-master(included in26.11and later)