Skip to content

Resolve Iceberg file paths spelled differently from the table location - #130082

Open
groeneai wants to merge 8 commits into
ClickHouse:masterfrom
groeneai:fix-iceberg-paths-spelled-differently
Open

groeneai wants to merge 8 commits into
ClickHouse:masterfrom
groeneai:fix-iceberg-paths-spelled-differently

Conversation

@groeneai

@groeneai groeneai commented Nov 8, 2026 •

Copy link
Copy Markdown
Collaborator

Closes: #129990

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 of Iceberg tables whose metadata spells file paths differently from the table location, as Spark, Impala, Dremio and DuckDB write them: file:/x, file://x and file:///x now name the same file, a relative location and 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 example hdfs://localhost:20500/... for /test-warehouse/...). Such tables failed with FILE_DOESNT_EXIST on 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 with FILE_DOESNT_EXIST for ata/persistent/..., and position deletes that name the data file as hdfs://localhost:20500/... while the manifest says /test-warehouse/... are silently not applied.

Root cause: IcebergPathResolver::resolve cut table_location.size() - table_root.size() characters off a path not starting with the location text, 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, else BAD_ARGUMENTS naming 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 in OPTIMIZE compare storageIdentity, 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 location of a renamed table copy (DuckDB's lineitem_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]

groeneai and others added 5 commits November 8, 2026 01:28
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]>
@groeneai

groeneai commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review (4 rounds)
  • ❌ pruning prefix not alias-safe for file:/ (file:///t/x starts with file:/): AGREE, values continuing the prefix with / are never pruned.
  • ❌ delete files without file_path bounds (Iceberg Java writes none for a delete file of several data files) lost row-group pruning: AGREE, they are pruned by the spelling-tolerant predicate.
  • ❌ delete files whose rows span top-level directories with different first bytes (object-store hash directories at a bucket root) lost row-group pruning: AGREE, the predicate prunes everything under the data path's scheme and authority except a further leading /.
  • ❌ path identity computed per distinct path per data file: AGREE, a file-name pre-filter skips it for other files' rows.
  • ❌ the substring rule (a path outside the location that contains the table path resolves from that occurrence) also matches mid-component: DISAGREE for this PR; byte-identical to master and pinned by the Unchanged gtest, kept because files earlier versions wrote through write.data.path sit where it points. expire_snapshots now keeps such an alias of a retained file (master deleted it).
  • ⚠️ expire_snapshots scenario could not tell selective retention from a no-op: AGREE, it now also expects the other expired manifest list to be deleted.
  • ⚠️ //, . or .. aliases inside a multi-file delete file on local/HDFS: DISAGREE as a blocker; same result on master, disclosed in the description.
  • ⚠️ mixed-version cluster workers: DISAGREE; an old worker gets the raw data path it already compares.
  • 💡 remove_orphan_files keeps comparing unnormalized keys for interior ///. aliases: as on master, outside this change.
  • 💡 test and robustness nits fixed.

@groeneai

groeneai commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. 05568_iceberg_paths_spelled_differently.sh builds each shape with clickhouse-local and fails on master every run: file:/// location with a file:/ manifest list outside the table directory, a file:/ location, a relative location, an unresolvable s3:// path, single-file and two-file position deletes spelled hdfs://... or with a leading //, and expire_snapshots with a respelled manifest list.
b Root cause explained? IcebergPathResolver::resolve matched the location as a string prefix and otherwise cut table_location.size() - table_root.size() characters, lengths of unrelated strings, so other spellings of the same directory became mangled keys. Position deletes, OPTIMIZE, the row estimate and expire_snapshots compared raw path strings.
c Fix matches root cause? Yes. Paths are resolved by component within one storage space, and every comparison of two metadata paths goes through the resolver's storageIdentity. No bound widened, no guard at the failing call.
d Test intent preserved / new tests added? New stateless test (9 scenarios, one asserting that delete-file row groups spelled like the data paths are still pruned) and gtests for the resolver, identity, delete bounds and deriveTableRoot. No existing test changed.
e Both directions demonstrated? Master: FILE_DOESNT_EXIST on warehouse/shared/..., ehouse/db/t/..., /warehouse/shared/...; deletes not applied ([1,2,3], [1,2,3,4,5,6]); expire_snapshots deletes the retained manifest list (count 2 instead of 1, then FILE_DOESNT_EXIST). Fix: all scenarios match the reference, 50/50 randomized runs.
f Fix is general across code paths? resolve, deriveTableRoot, resolveForCatalog, the iterator and OPTIMIZE bound checks, both OPTIMIZE deduplication maps, the bitmap and streaming delete transforms (pruning literal and row filter), the row estimate, expire_snapshots. RemoveOrphanFiles fails closed through resolve.
g Fix generalizes across inputs (params/datatypes/wrappers)? Schemes s3/s3a/abfss/hdfs/file/none; filesystem paths (a//b = a/b) vs byte-exact object keys; relative/absolute table roots; absent (pruned by the predicate), one-sided, truncated and equal delete bounds (deletion vectors); both delete transforms.
h Backward compatible? (maintainer-approved exception only) Yes. The resolver returns the previous string wherever the previous one named an existing file (gtest rows; prototype over 644 metadata files and 120 URI shapes). No setting or protocol change: reference_data_file_path is already serialized, and older workers accept it.
i Invariants and contracts preserved? Foreign-namespace paths are still returned unchanged; an unresolvable retained path aborts expire_snapshots before anything is deleted; the delete transforms only drop rows, so positions stay sorted per source; delete-file row groups are pruned only when all their values continue the data path's scheme and authority with a byte above /, and their range excludes it.

Session id: cron:clickhouse-impl-slot-4:20261108-034700

@groeneai

groeneai commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator Author

cc @SmitaRKulkarni @arsenmuk, could you review this and add the can be tested label so CI runs? IcebergPathResolver now resolves a metadata path by its storage and path components instead of by a string prefix of location, so file:/x, file:///x, relative locations and files outside the table directory reach the right object, and position deletes, OPTIMIZE and expire_snapshots compare paths by that resolved identity.

@clickhouse-gh

clickhouse-gh Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [38be468]

Summary: ❌

job_name test_name status info comment
Finish Workflow FAIL
python3 ./ci/jobs/scripts/workflow_hooks/can_be_merged.py --review-threads FAIL

AI Review

Summary

The 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 OPTIMIZE. One blocker remains.

Findings

❌ Blockers

  • src/Storages/ObjectStorage/DataLakes/Iceberg/Compaction.cpp:295–308: File deduplication still discards source-manifest membership. When two retained snapshots reference different manifests containing the same raw data-file path, getPlan reuses a single DataFilePlan owned by the first manifest. writeMetadataFiles emits that file only under its original owner, omitting it from the later snapshot. On the exact head's ARM ASan/UBSan binary, changing the new merged_manifest fixture's file:/m/.../data-e38afe4a-e866-4735-a1fe-dcb256118221.parquet entry to /m/.../data-e38afe4a-e866-4735-a1fe-dcb256118221.parquet, then applying the test's deletion and compaction, changes current rows from [1,3,10,11] to [10,11]. The original fixture retains all four rows. This is an inherited defect in the same ownership invariant; the alias-specific regression is fixed. Preserve each source-manifest membership independently of file deduplication, reject the unsupported history before committing, or explicitly link an issue tracking this inherited defect. Evidence was added to the existing compaction thread.
Tests
  • ⚠️ Extend the new compaction regression with the identical-path variant and verify the current snapshot retains [1,3,10,11] after OPTIMIZE. Both the control and failing variant were reproduced against head 38be468444d732abcbb7244eb80290a48754af5c; both queries completed successfully without sanitizer diagnostics.
Final Verdict

Status: ❌ 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.

@clickhouse-gh clickhouse-gh Bot added pr-bugfix Pull request with bugfix, not backported by default can be tested Allows running workflows for external contributors comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. labels Nov 8, 2026
…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]>
@clickhouse-gh

clickhouse-gh Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 38be46844 with master 962432765 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

22 object files changed (+120.19 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Storages/ObjectStorage/DataLakes/Iceberg/PositionDeleteTransform.cpp.o 342.15 KiB 398.42 KiB +56.27 KiB (+16.45%)
src/CMakeFiles/dbms.dir/Storages/ObjectStorage/DataLakes/Iceberg/IcebergPath.cpp.o 66.05 KiB 89.58 KiB +23.53 KiB (+35.62%)

716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

81 translation units recompiled, 687 s compile time in total, 81 of them have a recent master baseline.

Job report

@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 19, 2026
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);

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.

[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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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

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.

[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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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]>

This branch has not been deployed

No deployments
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 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

1 participant