Repository navigation
Conversation
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-5:20260710-231500 |
|
cc @scanhex12 @kssenii — could you review? This fixes Iceberg |
|
Workflow [PR], commit [fe5f360] Summary: ❌
AI ReviewSummaryThe PR makes experimental Iceberg Findings❌ Blockers
Tests
Missing context / blind spots
Final Verdict❌ Block on the unresolved wrong-result paths: preserve or reject mismatched partition specifications, and preserve retained snapshots' row sets. The cache and expiration limitations remain separately recorded above. No new inline findings or thread replies were submitted; existing author decisions were left in their threads. |
|
Addressed both review comments in 4a7b492 (per-data-file plan keying + strengthened regression test). Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-3:20260711-033400 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-0:20260711-041800 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-0:20260711-051900 |
|
Both concerns addressed in b89a011. Statistics and the partition index now live on Comment 1 (partition values per manifest): Comment 2 (statistics unioned across files): each
Regression test |
|
Thanks — both addressed in 3d17b02. A. Evolution check thrown before B. Metadata object still mostly synthetic. New regression Report URL for the original failure and the pre-PR validation gate for this change are below. |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-0:20260711-073400 |
|
The Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-0:20260711-090700 |
|
Both addressed in 2ceb1b2. 1. Refs to skipped (delete-only) snapshots. After the replay loop, prune any 2. next-row-id (format v3). Reset Regression coverage (no-Spark, local,
Verified both directions locally (IcebergLocal): pre-fix the tag survives pointing at an absent snapshot and |
|
Fixed in cd462d2. The deep-copy metadata bootstrap now clears `partition-statistics` alongside `statistics` in the snapshot-state reset block, so a `partition-statistics` array copied from Spark/Flink source metadata no longer publishes a dangling `statistics-path` after `clearOldFiles` deletes the pre-compaction `metadata/` subtree (SnapshotFilesTraversal treats both as reachable files). Regression: `test_optimize_clears_partition_statistics` injects a `partition-statistics` entry pointing at a metadata-side file, runs OPTIMIZE, and asserts the compacted metadata carries no `partition-statistics`. Verified both directions locally: pristine HEAD leaves the dangling entry, the fix clears it. |
|
The Root cause (verified locally with IcebergLocal + a hand-crafted nested-rename metadata):
The semantic lossy-evolution guard, per-data-file rewrite, and DROP-COLUMN rejection from the earlier rounds are unchanged and still exercised. |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-0:20260711-103800 |
|
Addressed in c246fc3. Concern 2 (commit-conflict data loss) — fixed. Concern 1 (decimal precision/scale in the type signature) — already covered; added a test to pin it. In this codebase Iceberg encodes decimal and fixed as string primitives ( |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-1:20260711-101900 |
CI finish ledger — c246fc3CI fully finished (Finish Workflow + Mergeable Check both green; only
Session id: cron:our-pr-ci-monitor:20260711-183000 |
|
Merged current master (8da8054) to resolve the conflict flagged by the conflict check. Master had merged the manifest-consolidation feature (#98178) plus the ORC-position-delete fix, which reworked the same `generateManifestFile` and compaction paths this PR touches. Reconciliation:
All prior CR fixes preserved. Builds clean. |
| partition_columns, | ||
| plan.partition_encoder.getPartitionValue(grouped_by_manifest_files_partitions[manifest_entry]), | ||
| /*partition_values=*/{}, | ||
| ChunkPartitioner(fields_from_partition_spec, current_schema->getArray(Iceberg::f_fields), context, sample_block_).getResultTypes(), |
There was a problem hiding this comment.
writeMetadataFiles still hard-codes every rewritten data manifest to the current default-spec-id, but per_file_partition_values comes from each source file's original partition_key_value. That is fine only when the table has never had partition evolution. writeConsolidatedManifestFile just above had to resolve the spec per manifest for exactly this reason.
A concrete trace is PARTITIONED BY (region), then DROP PARTITION FIELD region (or ADD PARTITION FIELD ...), DELETE, OPTIMIZE. The old files still carry the old spec's tuple, but this call serializes them under the current spec. generateManifestFile then indexes one value per current partition column in effective_partition_values (IcebergWrites.cpp:507-535), so a changed-arity spec can read past the end of the tuple; if the arity happens to match, the manifest still gets stamped with the wrong partition metadata and partition pruning goes wrong.
Can we carry the source manifest's partition_spec_id and derived partition types through ManifestFilePlan here, mirroring writeConsolidatedManifestFile, instead of unconditionally using default-spec-id?
CI finish ledger — 93987adEvery failure below has an owner. This ledger covers the post-merge head (slot-3 duplicate-setting Style fix on top of the origin/master conflict-resolution merge). Supersedes the pre-merge ledger (issuecomment-4948318768, head c246fc3).
Finish Workflow = SUCCESS; Style check (cpp) = SUCCESS on this head (duplicate Session id: cron:our-pr-ci-monitor:20260717-220147 |
|
📊 Cloud Performance Report ✅ AI verdict: no significant changes detected. K_source=6 K_base=30 flagged=0/65 clickbench🟢 No significant changes tpch_adapted_1_official🟢 No significant changes Debug info
|
CI finish ledger - edbcf7eEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
All check runs completed and Session id: cron:our-pr-ci-monitor:20261011-030008 |
| data_file_ptr = it->second; | ||
| } | ||
| plan.partitions[partition_index].push_back(data_file_ptr); | ||
| plan.snapshot_id_to_data_files[snapshot.snapshot_id].push_back(plan.partitions[partition_index].back()); |
There was a problem hiding this comment.
snapshot_id_to_data_files is storing the same DataFilePlan for every snapshot that still references a source file, and the delete-attachment pass below mutates that shared plan once before writeDataFiles rewrites it.
That means a later position delete is baked into the single rewritten patched_path for that file and then reused by older snapshots during history replay. A simple APPEND(F) -> DELETE some rows from F -> OPTIMIZE history will therefore make time travel to the pre-DELETE snapshot read the post-delete file.
I think this needs snapshot-specific rewrite lineage here (or, equivalently, separate rewritten files for distinct delete spans) rather than one shared rewritten file per source path.
CI finish ledger - 162eed9Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
All check runs completed and Session id: cron:our-pr-ci-monitor:20261017-220006 |
|
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. |
`OPTIMIZE TABLE` on an Iceberg v2 table failed with
Code: 48. DB::Exception: Position deletes are only supported for data files
of Parquet format in Iceberg, but got ORC. (NOT_IMPLEMENTED)
on a snapshot that `SELECT` reads correctly. The carrier is a current snapshot
holding, in one partition, a non-Parquet data file whose sequence number is not
above a position delete's, where that delete references only Parquet data files.
Such a table has to be written by another engine, because ClickHouse's own
DELETE and UPDATE refuse while a non-Parquet data file is live in the current
snapshot (`validateSnapshotDataFileFormatsForMutation`).
Compaction and the read path both decide whether a position delete applies to a
data file, and compaction's decision had one term fewer. `IcebergIterator::next`
also tests the delete's `lower_reference_data_file_path` and
`upper_reference_data_file_path` against the data file's own
`data_object_file_path_key`; `getPlan` tested only the partition value and the
sequence number, so it handed a delete that provably does not name a data file to
`addPositionDeleteObject`, which rejects a non-Parquet data file. This adds that
bounds test, and only it, so the per-pair decision matches the read path's. As on
read, absent bounds mean no pruning, so a delete recording no bounds still
reports the same error a `SELECT` reports.
Results were never wrong: both delete transforms call
`filterChunkToCurrentDataFile`, so an over-attached delete could not delete
another file's rows. The change only shrinks the attachment set, and compaction's
candidate set is a superset of the read path's, so no delete the read path
applies can be lost. `writeDataFiles`' precondition still holds: a previously
over-attached non-Parquet file now takes the already-exercised no-deletes branch.
Equality deletes are unaffected. `getPlan` collects only position deletes, an
OVERWRITE snapshot carrying equality deletes is refused earlier by
`overwriteIsPositionDeleteOnly`, and `addEqualityDeleteObject` has no format
precondition.
The pass still buckets deletes by partition value without
`common_partition_specification`, so the two predicates match per pair, not as a
whole. That is left alone: data compaction resolves one default partition spec
and rewrites every manifest under it, so narrowing the bucket per spec would fix
one term of a path that then collapses all specs to one.
The regression test is an integration test because the snapshot needs an
external writer. It builds the mixed-format table with Spark and asserts the row
set is unchanged across the `OPTIMIZE`. Its arming conditions are asserted
separately, and they hold on the unfixed build, so a green run measures the fix
rather than the fixture.
Related: ClickHouse#110069, where this was reported, and ClickHouse#102508 / ClickHouse#105893, which fixed the
mutation half of the same restriction.
|
@groeneai continue the work on this PR |
|
Merged master and resolved the conflicts in 4374d0f (master's per-file partition spec and position-delete bounds in On the merged build: The PR is ready for review. |
Iceberg data compaction now reads each data file with the schema it was written under and keeps each rewritten file listed under its source schema, rejects compaction after a lossy schema evolution, an added column or into a non-Parquet format, writes per-file partition values and statistics, preserves table metadata on replay (committed schema ids, refs, partition statistics, next-row-id), and treats a lost or unconfirmed metadata commit safely: the rewritten files are removed only when the commit is certainly lost, and the version hint is kept out of the cleanup. Squashed from ClickHouse#110069 after merging master. Co-Authored-By: Claude Opus 5.5 <[email protected]>
4374d0f to
bc6c8f3
Compare
The rename, dropped/added column, no-op, requiredness, partition spec and format version 3 cases of test_writes_optimize_after_rename.py run plain SQL against one table, so they move to 05508-05510, over IcebergLocal and IcebergS3 (MinIO). Each case keeps its assertions: the compaction ran (the position delete is gone), or the refusal names its own guard and leaves the data and time travel intact. The integration module keeps only the cases that edit the metadata files directly or stage a version-hint failure. On the master snapshot 39b9f2d the rename, partition spec and refusal cases fail; on this branch they pass. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The test built its fixture with 20 single-row INSERTs, so each run made 22 Iceberg commits and OPTIMIZE re-read every manifest of every snapshot with the metadata cache disabled. The flaky check runner is disk-bound (about 97% iowait during the sequential runs) and every run took 183-206 s on msan, over the 180 s limit. One INSERT of the same 20 rows writes one data file per partition, which is enough: compaction runs whenever a positional delete exists, and the arity guard rejects the first rewritten file. Per run this is 3 metadata versions instead of 22, and 64 file opens instead of 449 (local query time 2.55 s -> 0.17 s). Master still aborts on the same OPTIMIZE, and the fixed server still reports ICEBERG_SPECIFICATION_VIOLATION and keeps all 18 rows. Also drop `no-parallel`: every run uses its own database and table path, so DETACH/ATTACH cannot interfere with another run (100 runs at 16 and 31 jobs). Co-Authored-By: Claude Opus 5.5 <[email protected]>
In the ParallelReplicas job, with `optimize_trivial_count_query = 0`, the probe's `SELECT count()` runs on two replicas, and both log the same metadata under one query id, so the test printed `[5,5] [5,5]` instead of `[5] [5]` (reproduced 3/3 locally with that job's profile and cluster). Read the distinct metadata contents first, as 05509 already does: replica duplicates collapse, while two different metadata versions would still show as two values. Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI finish ledger - fe5f360Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
All check runs completed and Session id: cron:our-pr-ci-monitor:20261106-010008 |
|
Fixing PR for the Iceberg rewrite error of prewhere_subcolumn_read_steps in Performance Comparison (iceberg_local/iceberg_s3, 1/3): #129658 |
Closes: #120833
Related: #117116
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Iceberg
OPTIMIZE(experimental compaction,allow_experimental_iceberg_compaction) now applies schema evolution: data files written under an older schema (for example beforeALTER TABLE ... RENAME COLUMN) are read by their own schema and remapped to the current one, so the compacted files keep the original values instead ofDEFAULT/NULL, and the rewritten metadata keeps the table's schemas, so the table stays readable instead of failing withICEBERG_SPECIFICATION_VIOLATION. IntoAvroorORCsuch a compaction is refused.Description
IcebergMetadata::optimizebuilds the compaction reader header from the table's current schema (getSampleBlock()), andCompaction.cppread/regenerated everything against the current schema, ignoring per-file schema ids. After schema evolution this had three consequences:StorageObjectStorageSource) handles this viagetInitialSchemaByPath+getSchemaTransformer; compaction did not, so a renamed column was compacted intoDEFAULT/NULL.createEmptyMetadataFilealways synthesizesschema-id 0from the current column names with fresh field ids, rebindingschema-id 0to different fields (ICEBERG_SPECIFICATION_VIOLATIONon the next read) and losing the field ids the data files reference.snapshot already registered with schema id ...).Fix:
writeDataFilesreads each data file by its own schema (getClickhouseTableSchemaById) and remaps it to the current schema viagetSchemaTransformationDagByIds, mirroring the normal read path. Position deletes are applied first (they reference original file row positions), then surviving rows are remapped.writeMetadataFilescarries the realschemas,current-schema-idandlast-column-idfrom the source metadata, and preserves each snapshot's originally committed schema id.AvroorORCis refused (NOT_IMPLEMENTED): only the Parquet reader resolves the rewritten files' columns by field id.Added a stateless regression (
05508_iceberg_optimize_after_rename_column, overIcebergLocalandIcebergS3): INSERT, DELETE (positional delete so compaction has work),RENAME COLUMN,OPTIMIZE; it asserts the renamed column keeps its original values (noNULL/DEFAULT), the deleted row stays deleted and the position delete is compacted away. It fails before this change (ICEBERG_SPECIFICATION_VIOLATION) and passes after.Verified locally on
IcebergLocal(format-version 2): before the fixOPTIMIZEleaves the table unreadable; after it the renamed column keeps its values, and compaction without a rename is unchanged.Workflow [PR]
Sync PR [sync-upstream/pr/110069]