Skip to content

Read Iceberg metadata files whose names have no version number - #130070

Open
groeneai wants to merge 5 commits into
ClickHouse:masterfrom
groeneai:iceberg-unversioned-metadata-file-name
Open

groeneai wants to merge 5 commits into
ClickHouse:masterfrom
groeneai:iceberg-unversioned-metadata-file-name

Conversation

@groeneai

@groeneai groeneai commented Nov 8, 2026 •

Copy link
Copy Markdown
Collaborator

Closes: #129988
Related: #130010

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

Iceberg metadata files whose names are not v<N>.metadata.json, v<N>-<uuid>.metadata.json or <N>-<uuid>.metadata.json were rejected with Bad metadata file name. Now such a file is read when iceberg_metadata_file_path, version-hint.text or a catalog names it, and the search for the latest metadata file skips it instead of failing the table (or ranks it by last-updated-ms with iceberg_recent_metadata_file_by_last_updated_ms_field). Closes #129988.

Description

On 26.10.2.103, icebergLocal(..., SETTINGS iceberg_metadata_file_path = 'metadata/vfinal.metadata.json') fails with BAD_ARGUMENTS although the setting is documented to read this exact path and Iceberg does not restrict metadata file names (duckdb-iceberg fixtures use vfinal.metadata.json, decimal_max_precision.metadata.json, ...). One such file in metadata/ also made a catalog-less table unreadable.

Root cause: getMetadataFileAndVersion threw for any name without a version, and every resolver calls it (explicit path and catalog pointer, version hint, listing).

Change:

  • the name parser returns "no version" instead of throwing; such a file gets version -1, so the next commit is version 0, like Iceberg Java's parseVersion;
  • the listing skips such files when ranking by version, as Iceberg Java's HadoopTableOperations does, keeps them when ranking by last-updated-ms, and when only such files exist, the error names them and both settings that read them;
  • catalog-less writes and destructive operations (INSERT, ALTER, OPTIMIZE, expire_snapshots, remove_orphan_files, ...) keep failing exactly where they failed on the name before, now with a message naming the file.

Validation: new 05568_iceberg_unversioned_metadata_file_name (fails on master, 50/50 randomized with the fix); 04061 keeps its queries, which now fail on the missing object (S3_ERROR) instead of on the name. The issue's own count() repro now passes the name and stops at the separate current-snapshot-id > Int64 overflow listed in #130010.

🤖 Generated with Claude Code


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

groeneai and others added 4 commits November 8, 2026 00:22
`getMetadataFileAndVersion` threw `Bad metadata file name` for any name other
than `v<N>.metadata.json`, `v<N>-<uuid>.metadata.json` or `<N>-<uuid>.metadata.json`,
and every resolver of the current metadata file goes through it: the explicit
`iceberg_metadata_file_path` (where a catalog's pointer also lands), the
`version-hint.text` branch and the catalog-less listing. Iceberg does not
restrict metadata file names (duckdb-iceberg fixtures use `vfinal.metadata.json`,
`decimal_max_precision.metadata.json`, ...), so a valid file could not be read
even when named explicitly, and one such file in `metadata/` failed the table.

Name parsing is now separate from file selection, following Iceberg Java:
- `tryGetMetadataFileVersion` keeps the old accept set and returns nothing
  where the old code threw; `getMetadataFileAndVersion` gives such a name
  version -1, so the next commit is version 0 (`BaseMetastoreTableOperations.parseVersion`);
- readers listing by version (also with `iceberg_metadata_table_uuid`) skip it
  (`HadoopTableOperations.findVersion`), readers ranking by `last-updated-ms`
  keep it, and when only such files exist a dedicated FILE_DOESNT_EXIST names
  one of them and both settings that read them;
- `ignore_metadata_pointer_overrides` callers (catalog-less writes and
  destructive operations) refuse such a table, as before, with a message that
  names the file: rooting a commit on the highest `v<N>` while an unversioned
  file may hold a newer state would drop that state, and `remove_orphan_files`
  would delete the file.

04061 keeps its three queries; the names are read now, so they fail on the
missing object (S3_ERROR) instead of on the name, and a regressed parser would
still print STD_EXCEPTION.

Closes ClickHouse#129988

Co-Authored-By: Claude Opus 5.5 <[email protected]>
With `iceberg_use_version_hint = 1` and a hint naming a `v<N>` file, the
catalog-less writer's listing keeps only `v<N>` names (the table's declared
scheme, as on master), so an unversioned name never reaches the refusal and
the write succeeds. The docs sentence saying such writes refuse to run was
therefore false in that configuration; drop it and keep only the reader
bullet.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A pointer (`iceberg_metadata_file_path`, the version hint or a catalog
path) to a name the temporary-file rule matches, such as
`<uuid>.metadata.json` or a name without a `.`, is still refused, as on
master. Only names that merely lack a version number are now accepted, so
scope the docs bullet to what the listing does when reading and drop the
"any name" sentence.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Remove a comment above the unversioned-name check that restated the exception message.

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 (click to expand)
Finding Verdict
⚠️ The docs said catalog-less writes refuse while metadata/ holds an unversioned name, but under iceberg_use_version_hint naming v<N> the scheme filter hides such names first (as on master) Agreed: the docs sentence was removed. The refusal itself is unchanged and still fires exactly where the old parser threw
⚠️ The docs said iceberg_metadata_file_path reads a file of any name, but a pointer to a <uuid>.metadata.json (the temporary name of a Hadoop-style commit) is still refused by the temporary-file rule Agreed on the docs: the bullet now only says what reading skips. The temporary-file rule is unchanged from master; no writer is known to commit such a name
💡 With the opt-in iceberg_list_only_v_prefixed_metadata_files, a metadata/v listing holding only unversioned names gets an error that does not mention the other files Noted: the setting is documented only for tables whose metadata files are all v<N>

@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. The issue's duckdb-iceberg fixtures: DESCRIBE icebergLocal('data/persistent/invalid_decimal_type', SETTINGS iceberg_metadata_file_path = 'metadata/decimal_max_precision.metadata.json') fails Bad metadata file name on master and on 26.10.2.103 every time; the new test fails on master every time.
b Root cause explained? getMetadataFileAndVersion threw for any name without a version number, and every resolver (explicit path and catalog pointer, version hint, listing) calls it, so a valid file whose name encodes no order was rejected and one such file failed the whole listing.
c Fix matches root cause? Yes. The parser reports "no version" instead of throwing; each caller decides: an explicit pointer reads the file, the listing skips it by version and ranks it by last-updated-ms, catalog-less writers fail exactly where they failed on the name before, now with a message naming the file.
d Test intent preserved / new tests added? New 05568_iceberg_unversioned_metadata_file_name (13 lines: three name shapes, three listing modes, version hint, writer refusal, only-unversioned). 04061 keeps its queries; its pinned code is now the missing-object S3_ERROR, so a regressed parser (STD_EXCEPTION) still fails it.
e Both directions demonstrated? 05568 and 04061 fail on master and pass with the fix; the duckdb DESCRIBE returns d Nullable(Decimal(38, 38)) with the fix. 05568 50/50 with randomized settings. Mutants for each branch of the new code fail the test, except dropping only the skip, which ranks such a file at -1 where it can never win.
f Fix is general across code paths? Every resolver uses this one parser (explicit, catalog pointer, version hint, reader and writer listing, Glue location listing). All 176 *iceberg* stateless tests: same failure set as master apart from 04061 and 05568.
g Fix generalizes across inputs (params/datatypes/wrappers)? Non-numeric v name, dash with a non-numeric prefix, no dash, Int32 overflow, .*; ranking by version, by table uuid and by last-updated-ms; with and without versioned files next to it.
h Backward compatible? (maintainer-approved exception only) Yes. Every name accepted before resolves to the same file and version; only names that threw change. Catalog-less writers fail exactly where they failed on the name before, now with a message naming the file. No setting change.
i Invariants and contracts preserved? Version >= 0 iff the name carries one; temporary-file rule unchanged; catalog-less writers never root on an unversioned file (refused before ranking), catalog writers after one commit version 0 as Iceberg Java does.

Session id: cron:clickhouse-impl-slot-5:20261107-234300

@groeneai

groeneai commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator Author

cc @scanhex12 @alesapin, could you review this and add the can be tested label so CI runs? getMetadataFileAndVersion no longer throws on a metadata file name without a version number (such as vfinal.metadata.json): an explicit pointer (iceberg_metadata_file_path, version hint, catalog) reads it, the listing skips it when ranking by version, and catalog-less writers still refuse, now with a message naming the file.

@clickhouse-gh

clickhouse-gh Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [6ee9662]

Summary: ✅


AI Review

Summary

The PR allows explicitly selected Iceberg metadata files without a parseable filename version, skips them during version-based discovery, and includes them during timestamp-based discovery. The new regression test covers explicit paths, listing policies, UUID selection, version hints, and refusal of catalog-less writes. No actionable findings.

Consumers of the new -1 version checked:

  • IcebergMetadata, background prefetch, and IcebergMetadataFilesCache retain the metadata path and signed version; TableStateSnapshot serializes the version as a signed integer.
  • Catalog inserts and retries pass it to FileNamesGenerator, which advances it to version 0 and derives the filename from the base metadata file.
  • Mutations, partition operations, compaction, snapshot expiration, and orphan traversal use the shared resolver: catalog pointers identify the committed file, while catalog-less listing rejects unversioned candidates reaching its ordering checks. Orphan traversal also retains the root path as its identity.
  • Glue metadata discovery consumes the selected path without requiring a nonnegative version.
Missing context / blind spots
  • ⚠️ No local ClickHouse binary or build directory is available, so the regression tests were reviewed but not executed locally. The inspected CI report has no failures, but its targeted stateless entry exposes no individual results for the new test; completion of that CI test would close the execution gap.
Final Verdict

Status: ✅ Approve

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

groeneai commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 1be292f

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Build profile diff infra, not from this PR (no ci/ file in the diff): all 8 readiness probes to the CI logs cluster hit Read timed out. (read timeout=3), so has_pr_data raised LogClusterNotReady: the endpoint never became ready. The job errored the same way on 48 PRs in the last 24 hours #129675 (mine, open)
PR praktika rollup of the row above #129675 (the owner above)

The other CIDB FAIL rows on this head are Config Workflow / Pre Hooks and Finish Workflow / Post Hooks of the runs before the can be tested label.

Session id: cron:our-pr-ci-monitor:20261108-073004

@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
…-metadata-file-name

Conflict in Iceberg/Utils.cpp: master counts temporary candidates in the metadata listing and gave MetadataFileWithInfo a fourth field; kept both.

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

clickhouse-gh Bot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 6ee966230 with master ffc535ce4 (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.

Compile time of recompiled translation units

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

Job report

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

Development

Successfully merging this pull request may close these issues.

Iceberg: metadata files with names other than vN/N-uuid are rejected, even when given in iceberg_metadata_file_path

1 participant