Skip to content

Iceberg: cache partition candidates per manifest - #115876

Closed
adonm wants to merge 8 commits into
ClickHouse:masterfrom
adonm:adonm/iceberg-manifest-candidate-cache
Closed

adonm wants to merge 8 commits into
ClickHouse:masterfrom
adonm:adonm/iceberg-manifest-candidate-cache

Conversation

@adonm

@adonm adonm commented Aug 21, 2026 •

Copy link
Copy Markdown

Related: #116235

Cache complete manifest partition-candidate vectors so repeated compatible predicates can skip the full manifest walk. Per-query min/max pruning still runs, and incomplete scans must not publish a candidate vector.

The latest revision removes the custom Boolean simplifier and preserves partition RPN structure. Caching is limited to predicate forms with a sufficient identity; set predicates and function chains are not cached. In particular, the diagnostic rendering of IN records set cardinality rather than contents and cannot safely identify a cached result. Reuse across different point literals requires the same supported partition RPN shape.

The standalone branch's duplicate definitions/extra brace are corrected. New result fixtures cover equal-sized sets and nested predicates; exact-head build and cache-counter tests are queued: https://github.com/adonm/ClickHouse/actions/runs/33950833278. The fixtures passed on a baseline binary, not yet on this revision. Cancellation/concurrency and configurable cache limits remain review work. Kept draft.

Changelog category (leave one):

  • Performance Improvement

Changelog entry:

Reuse complete Iceberg manifest partition candidates for supported repeated partition predicates while retaining per-query min/max filtering.


Original implementation assisted by DeepSeek V4 Pro; follow-up revisions also used AI assistance.

@CLAassistant

CLAassistant commented Aug 21, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@rienath

rienath commented Aug 24, 2026

Copy link
Copy Markdown
Member

Looks like AI one-shot. You also filed 4 PRs simultaneously. Consider opening an issue instead

@adonm

adonm commented Aug 25, 2026

Copy link
Copy Markdown
Author

@rienath thanks for the feedback. I've moved the full context into #116235 (measurements, repro, landing order).

This PR is the manifest prune cache, fifth in that order. It caches the complete partition-candidate row vector per manifest (keyed by snapshot, manifest path, partition condition, and schema IDs), so warm queries skip the full manifest walk while min/max pruning still runs per query.

I'll rebase all six onto master and update here once fork validation is green.

adonm added 3 commits August 25, 2026 05:46
Keep the manifest prune cache current with master.
…st query ids

The pruner's KeyCondition is built from the full query filter, so its RPN
contains UNKNOWN atoms for non-partition conjuncts and the serialized key
changed with every point literal, defeating cross-literal reuse.
Canonicalize the RPN with three-valued logic (UNKNOWN AND x -> x,
UNKNOWN OR x -> UNKNOWN, NOT UNKNOWN -> UNKNOWN) before serializing.

The stateless test now uses unique query ids per run: query_log persists
on a warm server, so fixed ids matched stale rows from earlier attempts.
adonm added a commit to adonm/ClickHouse that referenced this pull request Sep 3, 2026
Replace debug-only `chassert` guards in `ManifestFilesPruner::partitionFilterHash` with real `LOGICAL_ERROR` checks on the `KeyCondition` `RPN` (`AND`/`OR`/`NOT`), so a malformed stack throws an exception in release builds instead of causing undefined behavior.

Document only, no behavior change: stateless `ManifestFileIterator::create` `table_snapshot_id` placeholder, `ParquetV3BlockInputFormat` row-group key unambiguity via `path.size()`, partition-only candidate sharing between data and delete iterators, derived `StorageInMemoryMetadata` `TableStateSnapshot` equality safety under `SYSTEM CLEAR ICEBERG METADATA CACHE`, and `DatabaseDataLake::tryGetTableImpl` global-context credentials, TTL race, and `ALTER DATABASE` over-invalidation.

Related: ClickHouse#116235
Related: ClickHouse#115873
Related: ClickHouse#115874
Related: ClickHouse#115876
Related: ClickHouse#115877
Related: ClickHouse#115878
adonm and others added 2 commits September 3, 2026 06:18
Replace debug-only `chassert` guards in `ManifestFilesPruner::partitionFilterHash` with real `LOGICAL_ERROR` checks on the `KeyCondition` `RPN` (`AND`/`OR`/`NOT`), so a malformed stack throws an exception in release builds instead of causing undefined behavior.

Document only, no behavior change: the stateless `ManifestFileIterator::create` `table_snapshot_id` placeholder, and why sharing one partition-candidate entry between data and delete iterators is safe.

Related: ClickHouse#115876
@clickhouse-gh clickhouse-gh Bot added the comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. label Sep 4, 2026
Remove duplicate definitions and an extra brace left on the standalone branch. Serialize supported partition RPN atoms without custom Boolean rewriting. Skip candidate caching for sets and function chains: the diagnostic rendering of `IN` contains cardinality, not values. Preserve reuse across different point literals with the same partition RPN shape. Add exact-result fixtures for equal-sized sets and nested predicates; patched-binary validation remains pending.
@maxknv maxknv added the external Author is not a member of the ClickHouse organization label Nov 2, 2026
@adonm

adonm commented Nov 9, 2026

Copy link
Copy Markdown
Author

Closing this draft to keep the review queue clear, per @rienath's request in #116235 to not have the whole series open at once.

The manifest-candidate caching notes and the predicate-identity caveats stay in #116235. Nothing here is being pursued right now; happy to reopen as a fresh, focused PR if the team wants this piece.

@adonm adonm closed this Nov 9, 2026
@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

close in a month if not active This will be closed in case of no information comp-iceberg Apache Iceberg tables: reading and writing Iceberg metadata (snapshots, manifests, schema evoluti... external Author is not a member of the ClickHouse organization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants