Repository navigation
Conversation
IcebergPathResolver::resolve matched the table `location` as a string prefix. Any other spelling of the same directory (`file:/x` vs `file:///x`, a relative location, a file outside the table directory) fell through to a branch that cut `table_location.size() - table_root.size()` characters, lengths of unrelated strings, and opened a mangled key (`ata/persistent/...`, `etadata/snap-...`). The constructor also turned a Hadoop `file:/x` location into `/file:/x`. Position deletes were matched to data files by raw string comparison everywhere, so deletes naming the data file as `hdfs://localhost:20500/...` while the manifest says `/test-warehouse/...` (Impala) were not applied. The resolver now parses a path into its storage space (scheme family via DataLake::tryParseStorageTypeFromString, authority; `file:` is local and has none) and components (a filesystem drops empty and `.` components, an object key keeps its bytes), and resolves it by component: under the location (also when one side has no scheme: the writer's default file system), in a foreign namespace, by the old table-root substring rule, or outside the location relative to the common parent directory of the table and the file. A path matching none of these throws BAD_ARGUMENTS naming the path, the location and the table path. Wherever the old code produced an existing file the result is byte-identical. `storageIdentity` is the one comparison of two metadata paths: position delete bounds (`matchPositionDeleteBounds`), the delete row filter, both OPTIMIZE deduplication maps, the row estimate and expire_snapshots retention (an unresolvable retained path fails the request, since deletion is irreversible). A delete file whose bounds do not show the data path's spelling is attached as `ThisFile` (`reference_data_file_path` = the raw data path, already serialized for cluster functions) and read without row-group pruning; a multi-file delete file keeps the raw-literal pruning only when its Parquet footer statistics show every value spelled like the data path. Closes ClickHouse#129990. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…th a spelling-tolerant predicate `matchPositionDeleteBounds` ran for every (data file, position delete) pair of a partition span and re-parsed the bounds and the data path on each call: two `storageIdentity` calls per non-matching deletion vector, four path parses per multi-file delete. With one deletion vector per data file on an unpartitioned table that is N^2 parses. The storage identity and the canonical prefix of a path are now computed once per file (`PositionDeleteMatchKey`): the iterator keeps the keys of the sorted delete files, a data file's key is computed on its first delete pair, and compaction stores it in `DataFilePlan`. The per-pair work is raw comparisons again. `isSameFile`, `isSpelledLike` and `tryResolve` lost their last callers and are removed; `canonicalPrefix` becomes public. The delete transform no longer reads the delete file's Parquet footer (a third read buffer and two uncached reads per pair) to decide whether the raw path literal may prune row groups. It prunes with `file_path = <raw> OR file_path < P OR file_path >= P_end`, where P is the raw prefix (scheme and authority, or `/`) of the data path and P_end is P with its last byte incremented: every string starting with P lies in [P, P_end), so only a row group whose values all start with P and whose range excludes the raw path is pruned, and a row group holding another spelling (`hdfs://...`) is always read. A relative data path (empty prefix) and a `ThisFile` delete file get no filter. The new test scenario checks that row groups of a ClickHouse-written delete file are still pruned (`ParquetPrunedRowGroups`). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…as-safe Delete file row groups are pruned with `file_path = <raw> OR file_path < P OR file_path >= P_end`, where P is the `canonicalPrefix` of the data file path and P_end is P with its last byte incremented. P now ends with the first byte of the first path component (`file:/t` for `file:/t/data/m`, `/t` for `/t/data/m`, `s3a://b/t` for `s3a://b/t/a`). Before, it ended at the separator (`file:/`, `/`), and `file:///t/data/m` or `//t/data/m`, the same file on a filesystem, started with it: a row group holding only such a spelling was pruned, and canonical bounds straddling `/` gave `None`. A canonical component is never empty, so its first byte is never `/`, and no spelling of the file with another scheme, authority or number of slashes shares the prefix. A relative path, or one with an empty, `.` or `..` component, has no canonical prefix. `matchPositionDeleteBounds` returned `ThisFile` when a `file_path` bound was missing, which disabled the pruning predicate, so a delete file without bounds was read whole for every data file. Iceberg Java >= 1.4.0 writes no `file_path` bounds for a delete file that references more than one data file (`PositionDeleteWriter.metrics()`), i.e. for every partition-scoped Spark or Flink position delete. A missing bound now attaches the delete file as `Range` and the predicate prunes its row groups; only two bounds prove a range for `None`. A present bound spelled otherwise than the data file path still gives `ThisFile`, since rows spelled like it may share the data path's prefix. Rows that do not name the data file by one of the exact spellings were matched by `storageIdentity` for every distinct `file_path` value, per data file, so N data files sharing one delete file cost N times its distinct paths. Every spelling of a file ends with its file name, so a row whose final name differs from the data file's is now rejected before computing an identity. The `expire_snapshots` scenario of the test now also expires a snapshot whose own manifest list must be deleted, so a no-op expire fails it; a new scenario writes the delete rows with a leading `//`, which the previous prefix pruned. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Delete file row groups are now pruned with `file_path = <raw> OR file_path < Q || '0' OR file_path >= Q_end`, where Q is the `canonicalPrefix` of the data file path, the raw text before its first component (scheme and authority, or `/`, always ending with `/`), and Q_end is Q with its final `/` replaced by `0`, the first string above every string that starts with Q. A row group is skipped only if all its values continue Q with a byte above `/` and its range excludes the raw data file path. `matchPositionDeleteBounds` returns `None` only for two bounds whose lower one is `>= Q || '0'` and whose range excludes the data file path. The previous prefix also included the first byte of the first component (`/t` for `/t/data/m`). A row group can be skipped only if all its values lie inside the pruned range, so a delete file whose rows name files under top-level directories with different first bytes (Iceberg's `ObjectStoreLocationProvider` with `write.data.path` at a bucket root writes `s3://bkt/<hash>/...`, or a table with data under several top-level directories) lost all min/max, dictionary and bloom filter pruning that `file_path = <raw>` gave on master, and two present bounds under such directories gave `ThisFile` where master gave `Range` or `None`. Alias safety needs only the byte right after Q: a spelling of the data file with another scheme, authority or relative form does not start with Q, one with more leading slashes continues Q with `/`, and a value continuing Q with a byte above `/` is another file or has an empty, `.` or `..` component inside the path (same as master). Since Q always ends with `/`, Q_end cannot wrap around. A new test scenario adds a row under `/zz/...` to a two-file delete file with one row group per row: each data file now skips both row groups it does not need (4 pruned in total); the previous prefix pruned 2. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Drop comments that narrate the new code (resolve rule list, member and overload docs that repeat their names) and condense the remaining multi-line docs; keep the domain invariants. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review (4 rounds)
|
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20261108-034700 |
|
cc @SmitaRKulkarni @arsenmuk, could you review this and add the |
|
Workflow [PR], commit [38be468] Summary: ❌
AI ReviewSummaryThe PR resolves Iceberg URI variants and uses resolved identities to match position deletes and deletion vectors. The compaction follow-up fixes the reported alias collision, but a normal merged-manifest history with identical file paths still loses current rows during Findings❌ Blockers
Tests
Final VerdictStatus: ❌ Block Preserve all manifest memberships or reject the affected history, with focused regression coverage; alternatively, explicitly track and link the inherited defect before merging this path-resolution fix. |
…not order IcebergStreamingPositionDeleteTransform merges each delete file as one stream of ascending positions. A delete file that names its data file in two spellings (now both matched, e.g. `/t/data/x.parquet` and `file:/t/data/x.parquet`) is sorted by `file_path`, so its positions for that data file form one ascending run per spelling: `2, 0`. The merge skipped position 0 and returned the row, while the bitmap transform deleted it. An unsorted delete file had the same effect. The streaming transform now checks that the positions of each source do not decrease. When the positions read at construction are out of order, no row has been emitted yet, so getPositionDeleteTransformer uses the bitmap transform instead and both modes return the same rows. Disorder found later (the second run starts in a later row group) cannot be undone without reading the whole file first, which is what the bitmap transform does, so it throws ICEBERG_SPECIFICATION_VIOLATION naming the data file and `use_roaring_bitmap_iceberg_positional_deletes`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes22 object files changed (+120.19 KiB total), 0 added.
716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units81 translation units recompiled, 687 s compile time in total, 81 of them have a recent master baseline. |
Conflicts with master's `IcebergPathResolver::storageIdentity` (ClickHouse#131782) and the per-data-file lookup of position delete files (4f04026): - `storageIdentity` keeps master's signature (throws) and normalization; the optional variant this PR needs becomes `tryStorageIdentity`, both computed from `resolveImpl`, so there is one identity. `storageIdentityOrThrow` is gone. The `is_filesystem` field is replaced by `BlobStorageDescription::isFilesystem()` (`local`/`hdfs`), the test master's identity uses. - `collectExpiredFiles` is master's: it already matches retained and expired files by identity. - `groupPositionDeletesByDataFile` keys the delete files whose bounds name one data file by `tryStorageIdentity` instead of the raw path, so a data file finds its delete files in any spelling; unresolvable bounds go to `other`. The iterator looks them up by the data file's identity (scope `ThisFile`) and checks only `other` with `matchPositionDeleteBounds`; `countDeletedRows` uses the same grouping. New gtest `GroupPositionDeletesByDataFile` fails with raw-path keys. - `getPositionDeleteTransformer` uses master's `usesStreamingPositionDeletes`, then falls back to the bitmap transform for unordered positions as before. - 05568: ClickHouse now writes one position delete file per data file, so the scenarios that need a delete file covering two data files read the Spark table `data_lake_corpus/iceberg/ice143_v2_position_deletes` (no `file_path` bounds) with its rows rewritten the same ways as before. Master returns 40 rows instead of 37 for the respelled rows. - gtest: `EXPECT_THROW((void)resolve(...))` for master's `[[nodiscard]]`; our identity test is renamed `TryStorageIdentity` next to master's `StorageIdentity`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
| /// from the compacted table. The map still deduplicates the same data file | ||
| /// referenced from multiple snapshots' manifest lists. | ||
| const auto & data_file_path = data_file->parsed_entry->file_path_key; | ||
| const auto data_file_path = persistent_table_components.path_resolver.storageIdentity(data_file->parsed_entry->file_path_key); |
There was a problem hiding this comment.
[Blocker] Preserve every manifest membership when deduplicating a data file
Keying this map by storageIdentity merges entries that previously had separate DataFilePlan objects, but each plan still has only one manifest_list owner. Consider location /t, root t, an append snapshot S1 with M1 containing /t/data/a.parquet, and a later append snapshot S2 whose replacement manifest M2 contains file:/t/data/a.parquet plus newly appended b.parquet. Include a subsequent position delete so OPTIMIZE TABLE actually runs. Both spellings of a.parquet now reuse the plan owned by M1.
writeMetadataFiles groups rewritten files only under that owner at Compaction.cpp:1248, then rebuilds each snapshot from its original manifest list at lines 1424–1434. Consequently the rewritten M2 contains only b.parquet: S2 loses the surviving rows of a.parquet, even though its summary still counts them. A successful commit also removes the original files through clearOldFiles.
Keep physical-file deduplication separate from the memberships needed to rewrite each source manifest (or reject this history before committing). Add a regression with these two append snapshots and a position delete, checking the current and retained snapshots after OPTIMIZE TABLE.
There was a problem hiding this comment.
Fixed in 38be468: data file plans are keyed by the raw path again, as on master, and 05568 now covers this history ([10,11] before, [1,3,10,11] after).
There was a problem hiding this comment.
[Blocker] 38be468 fixes the differently-spelled example, but the manifest-membership loss remains when both manifests use the same raw file_path.
At Compaction.cpp:295–308, the later manifest reuses the existing DataFilePlan, whose only manifest_list remains the first manifest (assigned at line 299). writeMetadataFiles then groups the rewritten file under only that owner at line 1248, so the later manifest loses it.
I reproduced this on the exact PR-head 38be468 ARM ASan/UBSan CI binary using the new merged_manifest fixture: replace its file:/m/warehouse/db/t/data/data-e38afe4a-e866-4735-a1fe-dcb256118221.parquet entry with /m/warehouse/db/t/data/data-e38afe4a-e866-4735-a1fe-dcb256118221.parquet, then run the test's deletion and compaction. The query succeeds, but the current rows change from [1,3,10,11] before OPTIMIZE to [10,11] afterward. The control with the original alias retains [1,3,10,11].
This identical-path case predates the PR; restoring the raw key removes the new alias collision but leaves the underlying ownership invariant broken. Please preserve every source-manifest membership separately from file deduplication, or reject this history before committing, and cover the identical-path variant. Alternatively, explicitly track the inherited defect in an issue linked from this PR.
There was a problem hiding this comment.
The identical-path case behaves the same on master ([10,11] there too), and #128472 adds the check that makes OPTIMIZE TABLE reject a history with a data file listed in several manifests before writing anything, so I keep it out of this PR.
Keying `path_to_data_file` by `storageIdentity` merged two spellings of one data file listed by different manifests into one plan, and a plan belongs to one manifest: `writeMetadataFiles` puts the rewritten file only into that manifest. With an append snapshot whose manifest list holds one manifest listing `b` and, again, the file of the first snapshot spelled `file:/...` (a merging append of Spark), the rewritten manifest of that snapshot held only `b`, so `OPTIMIZE` dropped the rows of the first file from the current snapshot and then removed the file. The map is keyed by the raw path again, as on master: each spelling gets its own plan in its own manifest, and both still get their position deletes, which are matched by identity. A same-spelling replacement manifest still loses its earlier files on master and here; that is not a path-spelling problem and stays out of this PR. The new scenario of 05568 (fixture `data_iceberg/merged_manifest`, written by ClickHouse, then the second manifest list rewritten) returns [10,11] before this change and [1,3,10,11] after it, as on master. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Closes: #129990
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed reading of Iceberg tables whose metadata spells file paths differently from the table
location, as Spark, Impala, Dremio and DuckDB write them:file:/x,file://xandfile:///xnow name the same file, a relativelocationand files outside the table directory are resolved relative to the common parent directory of the table and the file, and position deletes and deletion vectors are matched to their data file when they spell its path with another scheme (for examplehdfs://localhost:20500/...for/test-warehouse/...). Such tables failed withFILE_DOESNT_EXISTon a mangled path, or kept deleted rows. Closes #129990.Description
On 26.10.2.103,
SELECT * FROM icebergLocal('data/persistent/column_mapping/warehouse/default.db/my_table')on DuckDB's test table fails withFILE_DOESNT_EXISTforata/persistent/..., and position deletes that name the data file ashdfs://localhost:20500/...while the manifest says/test-warehouse/...are silently not applied.Root cause:
IcebergPathResolver::resolvecuttable_location.size() - table_root.size()characters off a path not starting with thelocationtext, and delete matching compared raw strings.Change: the resolver parses a path into its storage (scheme family, authority;
file:has none) and components, resolving by component: under the location, in another namespace, outside the location relative to the common parent directory, elseBAD_ARGUMENTSnaming the path, the location and the table path. The previous output is unchanged wherever it named an existing file. Position delete matching (also the per-data-file lookup of delete files) and the deduplication of delete files inOPTIMIZEcomparestorageIdentity, computed once per file. The streaming delete reader switches to the bitmap one when the delete rows it reads first name a data file in two spellings, and throws if it meets them later. Delete files keep row-group pruning; the predicate never prunes a row group holding a path with another scheme, authority or number of leading slashes.Validation: a new stateless test (fails on master) and resolver gtests; the maintainer's fixture tests 05716, 05743, 05782, 05783 and 05725 now pass. Not fixed here: a relative
locationof a renamed table copy (DuckDB'slineitem_iceberg_no_hint) stays unreadable, now with an unmangled path; as on master, a multi-file delete row spelling its data file with//,.or..among rows spelled like the data path (local/HDFS), and in streaming mode a second spelling in delete rows the merge never reaches, are not applied (no known writer does either).🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/130082]