Skip to content

Add basic implementation of DROP PARTITION for Iceberg - #111219

Merged
Diskein merged 25 commits into
masterfrom
dk-iceberg-drop-partition-base
Sep 22, 2026
Merged

Diskein merged 25 commits into
masterfrom
dk-iceberg-drop-partition-base

Conversation

@Diskein

@Diskein Diskein commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

This PR introduces support for ALTER DROP PARTITION on iceberg tables

  • supports transformations in partition expression e.g icebergBucket and etc
  • removes only manifests which were present on the moment of execution of a query
  • does not support catalogs
  • does not support schema evolution
  • does not support partition evolution
  • does not support "mixed manifests", when one manifest file has data files from different partitions

Related: #105198
Related: #109288

Changelog category (leave one):

  • Experimental Feature

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

Adds experimental support for ALTER TABLE ... DROP PARTITION on standalone Iceberg tables. The operation currently requires Iceberg format-version 2 with a single non-evolved partition spec and does not support catalog-backed tables.


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

Version info

  • Merged into: 26.10.1.461-master (included in 26.10 and later)

@clickhouse-gh

clickhouse-gh Bot commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [a05f715]

Summary: ✅


AI Review

Summary

This PR adds experimental ALTER TABLE ... DROP PARTITION support for standalone Iceberg tables by finding the target partition's files, publishing a new DELETE snapshot, and wiring docs and tests around the whole-manifest-only behavior. I would not merge it yet: two blocker-level correctness gaps remain in the current code, and both still affect valid existing Iceberg tables.

Findings

❌ Blockers

  • [dismissed by author -- https://github.com/ClickHouse/ClickHouse/pull/111219#discussion_r4046361215] [src/Storages/ObjectStorage/DataLakes/Iceberg/AlterDropPartitionExecutor.cpp:86-92] DROP PARTITION still compares the user-supplied partition tuple against the raw manifest carriers with accurateEquals, but manifest deserialization leaves some supported Iceberg partition values in non-ClickHouse carriers. In-tree code already documents both cases: DateTime64 identity partitions are stored in manifests as plain Int64 (src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergWrites.cpp:681-683), and decimal identity partitions come back from Avro as binary String blobs (src/Storages/ObjectStorage/DataLakes/Common/AvroForIcebergDeserializer.cpp:225-230). Because partitionEquals does not do the normalization that ManifestFilesPruner::canBePruned already does for the same values, identity(DateTime64(...)) drops miss the target partition and become no-ops, while identity(Decimal(...)) drops throw BAD_TYPE_OF_FIELD. Suggested fix: coerce each manifest partition value to the declared partition_types before comparing, or reuse the normalization helper from ManifestFilesPruner::canBePruned, and add focused regression coverage for one DateTime64 and one decimal identity partition.
  • [dismissed by author -- https://github.com/ClickHouse/ClickHouse/pull/111219#discussion_r4015512163] [src/Storages/ObjectStorage/DataLakes/Iceberg/AlterDropPartitionExecutor.cpp:533-547], [src/Storages/ObjectStorage/DataLakes/Iceberg/SnapshotSummary.cpp:227-239] The new DROP PARTITION path now rejects parent snapshots whose summary omits delete-family totals such as total-delete-files, total-position-deletes, or total-equality-deletes. Those fields are optional on valid Iceberg tables, and the rest of our Iceberg write path already treats a missing parent delete total as 0 (src/Storages/ObjectStorage/DataLakes/Iceberg/MetadataGenerator.cpp:97-107). We even have an integration regression test for exactly that metadata shape in manifest compaction (tests/integration/test_storage_iceberg_with_spark/test_manifest_compaction.py:1786-1798). As written, DROP PARTITION will fail with Missing required snapshot summary field ... on older Spark or removeOrphanFiles tables before it can commit anything, which is a backward-compatibility break on existing data. Suggested fix: require only the table-wide data totals here, and default missing delete-family totals to 0, matching setSnapshotTotals.
Final Verdict

❌ Changes requested. The feature is close, but the current implementation still rejects some valid historical Iceberg tables and silently misses others when manifest partition values are not already in the exact ClickHouse Field carrier expected by partitionEquals.

LLVM Coverage Report

Measured on commit a05f715.

Metric Baseline Current Δ
Lines 88.10% 88.10% +0.00%
Functions 91.70% 91.70% +0.00%
Branches 79.40% 79.40% +0.00%

Changed lines: Changed C/C++ lines covered: 458/555 (82.52%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-experimental Experimental Feature label Jul 21, 2026
@mintlify

mintlify Bot commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
ClickHouse-docs 🟢 Ready View Preview Sep 22, 2026, 5:34 PM

@Diskein
Diskein marked this pull request as draft July 21, 2026 13:07
@mintlify

mintlify Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
ClickHouse-docs 🟡 Building – Jul 21, 2026, 11:55 AM

@Diskein Diskein added pr-feature Pull request with new product feature and removed pr-experimental Experimental Feature labels Jul 21, 2026
@Diskein
Diskein marked this pull request as ready for review July 21, 2026 16:45
@Diskein Diskein changed the title Iceberg: add whole-manifest DROP PARTITION Add basic implementation of DROP PARTITION for Iceberg Jul 21, 2026
@Diskein
Diskein requested a review from scanhex12 July 21, 2026 16:46
@clickhouse-gh

clickhouse-gh Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 37 queries analysed

This PR adds Iceberg ALTER DROP PARTITION support (new executor, snapshot-summary delta accounting, a failpoint, and an avro submodule bump) — it touches only data-lake write/metadata paths and does not modify the general query-execution hot path. None of the flagged ClickBench queries (13, 16, 18, 32) read Iceberg tables, so the observed +12–23% deltas cannot plausibly be caused by this change. All four sit inside master's current variance band (Q16 was also intrinsically noisy and Q32's measurements were noisy), so they are downgraded to not-sure as run-to-run variance rather than real regressions.

clickbench

⚠️ 4 inconclusive

Flagged queries (4 of 43)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 13 not_sure 345 388 +12.5% <0.0001 This PR only adds Iceberg ALTER DROP PARTITION plumbing; a ClickBench SELECT never touches that code path, so the +12.5% within-band delta is run-to-run variance.
⚠️ 16 not_sure 556 654 +17.4% <0.0001 Flagged +17.4%, but the diff only adds Iceberg DROP PARTITION code that this query never executes; the query is also intrinsically noisy, so this is not a PR effect.
⚠️ 18 not_sure 918 1056 +15.1% <0.0001 The +15.1% sits inside master's current variance band and the PR touches only Iceberg partition-drop logic unrelated to this SELECT, so this is noise.
⚠️ 32 not_sure 752 926 +23.1% <0.0001 Change is +23.1% but within the wide variance band and the measurements were noisy; the Iceberg-only diff cannot touch this query, so this is variance.

Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on.

tpch_adapted_1_official

🟢 No significant changes

Debug info
  • StressHouse run: bdb16c32-674e-4e8d-9c87-2161de0ad9a5
  • MIRAI run: 9d9308ed-f5d6-44c5-85f0-46c271c8220f
  • PR check IDs:
    • clickbench_1368536_1790107130
    • clickbench_1368542_1790107130
    • clickbench_1368548_1790107130
    • tpch_adapted_1_official_1368555_1790107130
    • tpch_adapted_1_official_1368570_1790107130
    • tpch_adapted_1_official_1368606_1790107130

@Diskein

Diskein commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

BTW: It seems that even this simple insert can produce mixed-partition manifest file in Trino: https://pastila.nl/?0261b2e1/2efeb43ffce4105a5b07c09763692bca#Q46e2iXOxgxYmlCqShSuOA==GCM, so it will be worth to support such case.

@alesapin @scanhex12 FYI

@clickhouse-gh

clickhouse-gh Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.50% 86.50% +0.00%
Functions 91.90% 91.90% +0.00%
Branches 78.70% 78.70% +0.00%

Changed lines: Changed C/C++ lines covered: 311/433 (71.82%) · Uncovered code

Full report · Diff report

@Diskein
Diskein enabled auto-merge September 22, 2026 17:05
@Diskein
Diskein added this pull request to the merge queue Sep 22, 2026
Merged via the queue into master with commit 4fcd761 Sep 22, 2026
178 checks passed
@Diskein
Diskein deleted the dk-iceberg-drop-partition-base branch September 22, 2026 22:37
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 22, 2026
alexey-milovidov pushed a commit to Libao-Yang/ClickHouse that referenced this pull request Oct 2, 2026
…s the Iceberg transforms

`PARTITION BY` accepts `toYearNumSinceEpoch`, `toMonthNumSinceEpoch`, `toRelativeDayNum` and
`toRelativeHourNum` as spellings of the Iceberg `year`/`month`/`day`/`hour` transforms, and since
ClickHouse#118583 the partition values of those transforms are computed by `icebergYear`/`icebergMonth`/
`icebergDay`/`icebergHour` (UTC, negative before 1970). `ALTER TABLE ... DROP PARTITION tuple(...)`
evaluated the user's expression as written, so the old spellings produced the ClickHouse function
values (saturated to 0 before 1970, `toRelativeHourNum` offset by 24, local-time for a zoned value)
and the operation removed the data files of a different partition.

The alias list now lives in one helper, `normalizeIcebergTransformFunctionName`, used by
`getPartitionField` (PARTITION BY), `parseFunction` (sort order) and `parsePartitionTuple`
(DROP PARTITION, top-level function of each tuple element). The DROP PARTITION docs of the engine
and the table function list the `iceberg*` functions and mention the aliases.

Tests: a stateless test drops pre-1970 day/hour/month/year partitions and a zoned day value with
the old spellings (and checks that the two-argument `toRelativeDayNum(x, tz)` is rejected); a Spark
test reads a pre-1970 table with `<column> = <value>` filters for all four transforms, the shape
reported in ClickHouse#119579, which no existing test covered for `hours`/`months`.

Related: ClickHouse#119579, ClickHouse#118583, ClickHouse#111219

Co-Authored-By: Claude Opus 5.5 <[email protected]>
zvonand added a commit to Altinity/ClickHouse that referenced this pull request Oct 15, 2026
Antalya 26.8 Backport of ClickHouse#111219: Add basic implementation of `DROP PARTITION` for Iceberg
@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 22, 2026

This branch was successfully deployed

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

Labels

comp-iceberg Apache Iceberg tables: reading and writing Iceberg metadata (snapshots, manifests, schema evoluti... hold Skip for auto-updating. pr-experimental Experimental Feature pr-synced-to-cloud The PR is synced to the cloud repo submodule changed At least one submodule changed in this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants