Skip to content

Iceberg manifest files compaction - #98178

Merged
SmitaRKulkarni merged 109 commits into
masterfrom
Compact_iceberg_manifest_files
Jul 16, 2026
Merged

SmitaRKulkarni merged 109 commits into
masterfrom
Compact_iceberg_manifest_files

Conversation

@SmitaRKulkarni

@SmitaRKulkarni SmitaRKulkarni commented Feb 27, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Experimental Feature

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Support iceberg manifest file compaction resolves #95174

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Note

Medium Risk
Adds a new OPTIMIZE code path that rewrites Iceberg metadata/manifest files in object storage, so failures could impact table snapshot consistency if edge cases aren’t handled. Guarded behind allow_experimental_iceberg_compaction and a new threshold setting to reduce unintended runs.

Overview
Adds OPTIMIZE TABLE ... MANIFEST to trigger manifest-only compaction for Iceberg tables, including parser/AST support, interpreter validation (disallowing FINAL/PARTITION/DEDUPLICATE/CLEANUP), and a new IStorage::optimizeManifestFiles() virtual wired through StorageObjectStorage to Iceberg metadata.

Implements Iceberg manifest consolidation by reading the current (HEAD) snapshot, regrouping live data files by partition, writing per-partition consolidated manifest files plus a new manifest list/metadata and updating the version hint; compaction is skipped when below a new setting threshold iceberg_manifest_min_count_to_compact (default 30). Adds integration tests covering correctness, time-travel, no-op behavior, and option incompatibility errors.

Written by Cursor Bugbot for commit 7df98d3. This will update automatically on new commits. Configure here.

Version info

  • Merged into: 26.7.1.1025 (included in 26.7 and later)

@SmitaRKulkarni
SmitaRKulkarni marked this pull request as draft February 27, 2026 10:01
@clickhouse-gh

clickhouse-gh Bot commented Feb 27, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [4166c57]

Summary: ✅


AI Review

Summary

This PR adds experimental OPTIMIZE TABLE ... MANIFEST support for Iceberg tables, including the parser/interpreter entry point, manifest-only rewrite path, catalog integration, docs, and a large regression suite. Most of the earlier lineage/spec/schema bugs are fixed in the current head, but two material issues remain: the new non-transactional catalog failure path is not atomic, and the manifest-list partition-summary rewrite still drops bounds for some legal partition types while the new regression does not actually assert that metadata.

Missing context / blind spots
  • ⚠️ I did not run the Iceberg integration suite in this environment; findings below are from the current PR head, the full PR diff, and the existing GitHub discussion.
Findings

❌ Blockers

  • [src/Storages/ObjectStorage/DataLakes/Iceberg/Compaction.cpp:873-898] The new compaction commit path is not atomic for non-transactional catalogs. writeMetadataFileAndVersionHint can publish the new metadata/vN.metadata.json and version-hint.text before catalog->updateMetadata runs, but cleanup only removes the rewritten manifests and the new manifest list. If the catalog update then fails, direct path readers can advance to the new replace snapshot while the catalog still points at the old metadata.
    Suggested fix: delay the version-hint update until after the catalog pointer succeeds, or make the catalog-failure cleanup remove the new metadata file and restore the previous hint.

⚠️ Majors

  • [src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergWrites.cpp:120-139, 657-674] The manifest-list partition-summary rewrite still serializes only a subset of legal partition types. dumpFieldToBytes already knows how to encode UInt32 and ordinary floating-point values, but generateManifestList still gates those paths through canDumpIcebergStats, which rejects them. Bucket partitions therefore keep lower_bound / upper_bound null after compaction, and the same applies to non-NaN float partitions.
    Suggested fix: use a dedicated partition-bound serializer, or at least expand canDumpIcebergStats to match the types dumpFieldToBytes already supports while keeping the contains_nan special case.
  • [tests/integration/test_storage_iceberg_with_spark/test_manifest_compaction.py:694-705] The new bucket-partition regression does not actually prove the contract it describes. It only round-trips rows through Spark, so it still passes when the live bug above leaves manifest-list partitions[*].lower_bound / upper_bound null.
    Suggested fix: read the rewritten manifest list back and assert non-null or exact bound bytes for the bucket partition summary.
Final Verdict

Changes are not ready to merge. The manifest-only rewrite still has a live partition-summary gap, and the new catalog failure path can expose an uncommitted snapshot to some readers.

@clickhouse-gh clickhouse-gh Bot added the pr-feature Pull request with new product feature label Feb 27, 2026
@divanik divanik self-assigned this Mar 3, 2026
@SmitaRKulkarni SmitaRKulkarni changed the title [WIP]Iceberg manifest files compaction Iceberg manifest files compaction Mar 10, 2026
@SmitaRKulkarni
SmitaRKulkarni marked this pull request as ready for review March 10, 2026 13:46
Comment thread src/Core/SettingsChangesHistory.cpp Resolved

@scanhex12 scanhex12 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, minor issues

@alexey-milovidov

Copy link
Copy Markdown
Member

Your PR was poisoned by the test 02346_text_index_bug108519_qcc_skip_index. It is fixed in master. Please update the branch.

{
auto catalog_filename = path_resolver.resolveForCatalog(generated_metadata_info.path);
const auto & [namespace_name, table_name] = DataLake::parseTableName(table_id.getTableName());
if (!catalog->updateMetadata(namespace_name, table_name, catalog_filename, new_snapshot.snapshot))

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.

writeMetadataFileAndVersionHint can already publish the new metadata/vN...json and update version-hint.text before this catalog step runs, but the cleanup lambda above only deletes the rewritten manifest files and the new manifest list. For a non-transactional catalog like Glue, if updateMetadata throws or returns false here, direct path readers can advance to the new replace snapshot while the catalog still points at the old one.

That breaks the atomic "commit or no-op" contract for OPTIMIZE TABLE ... MANIFEST. Please either defer the version-hint update until after the catalog pointer succeeds, or extend cleanup to remove the new metadata file and restore the previous hint on catalog failure.

@clickhouse-gh

clickhouse-gh Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 80.00% 85.80% +5.80%
Functions 92.20% 92.70% +0.50%
Branches 72.00% 77.90% +5.90%

Changed lines: Changed C/C++ lines covered: 273/869 (31.42%) · Uncovered code

Full report · Diff report

@SmitaRKulkarni
SmitaRKulkarni added this pull request to the merge queue Jul 16, 2026
Merged via the queue into master with commit 65a8938 Jul 16, 2026
177 checks passed
@SmitaRKulkarni
SmitaRKulkarni deleted the Compact_iceberg_manifest_files branch July 16, 2026 13:13
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 16, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…anifest_files

Iceberg manifest files compaction
zvonand added a commit to Altinity/ClickHouse that referenced this pull request Sep 14, 2026
…talya_26_6

Antalya 26.6: Backport of ClickHouse#98178 Iceberg compaction using optimize

This branch was successfully deployed

1 active deployment
staging - docs — 4166c57b Deployed Jul 14, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-experimental Experimental Feature pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add an opportunity to compact manifest files in Iceberg

6 participants