Skip to content

Skip Parquet row groups of Iceberg data files by JOIN runtime filters - #129717

Merged
murphy-4o merged 10 commits into
ClickHouse:masterfrom
groeneai:iceberg-join-runtime-filter-row-group-pruning
Nov 12, 2026
Merged

murphy-4o merged 10 commits into
ClickHouse:masterfrom
groeneai:iceberg-join-runtime-filter-row-group-pruning

Conversation

@groeneai

@groeneai groeneai commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #128108

Changelog category (leave one):

  • Performance Improvement

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

Iceberg reads skip the Parquet row groups that cannot match a JOIN runtime filter. Controlled by the setting use_join_runtime_filters_for_iceberg_pruning.

Description

#128145 skips whole Iceberg data files that cannot match a JOIN runtime filter. A file that is read is still decoded in full: the Parquet reader prunes row groups only by the filter known at planning time, and the runtime filter exists only once the build side has finished. This PR applies the same check to the row groups of each file read:

ReadFromObjectStorageStep::initializePipeline
  FormatFilterInfo::join_runtime_filters      ← the runtime filters applied to the read
Parquet::Reader::prefilterAndInitRowGroups    ← at file open
  tryGetJoinRuntimeFilterKeyCondition         ← once built: key IN (...) or [min, max], built once, shared by the readers
  checkInHyperrectangle                       ← skip the row groups whose min/max cannot match
  • The probe side opens its first file after the build side has finished, so the filters are ready (RuntimeFilterLookupsBeforeBuildFinished = 0 in the runs below). A file opened earlier is read in full.
  • A file with skipped row groups writes no query condition cache entry and no cached row count, since its read no longer returns all its rows.
  • Not pruned: files read under a schema transform (old column names) and lazy materialization reads.
  • No new setting; also requires input_format_parquet_filter_push_down. New profile event ParquetRuntimeFilterPrunedRowGroups.

TPC-DS SF1 on Iceberg, release build, each fact table one data file sorted by the date key, 100k-row row groups: the 99 queries 13.7 → 11.0 s at 4 threads, 10.7 → 9.5 s at 16 threads; 81 queries skip row groups (q72 1886 → 328 ms); results equal. Same tables unsorted: geomean 0.99x / 0.98x. CI perf: one query in join_runtime_filter.xml (locally 27 → 12 ms).

Not covered: plain Parquet files, other data lakes, ORC.


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

Version info

  • Merged into: 26.11.1.2054-master (included in 26.11 and later)

groeneai and others added 3 commits November 6, 2026 07:02
ClickHouse#128145 skips whole Iceberg data files whose manifest bounds cannot contain a key of a hash JOIN's
runtime filter. Inside the files that are read, the Parquet reader still decoded every row group:
its only statistics-based row-group pruning input is `FormatFilterInfo::key_condition`, built once
from the plan-time `filter_actions_dag`, which never contains the runtime filter (that is moved into
PREWHERE as `__applyFilter`, which `KeyCondition` cannot interpret anyway).

The read now hands the runtime filters to the format through
`FormatFilterInfo::join_runtime_filters`. Once every filter is built, one `KeyCondition` per
`FormatFilterInfo` is built from them with `buildRuntimeRangePredicate` (the `key IN (exact values)`
/ `key BETWEEN min AND max` predicate that MergeTree and ClickHouse#128145 use), on the column layout of
`key_condition`, and `Reader::prefilterAndInitRowGroups` drops the row groups whose statistics cannot
satisfy it, next to the static `key_condition` check. The probe-side reader opens its first file only
after the build side has finished (`JoiningTransform::prepare` does not pull the probe input before),
so the check at file open sees finished filters; a reader that opened a file earlier would not prune
it.

Iceberg only, gated by `use_join_runtime_filters_for_iceberg_pruning`,
`enable_join_runtime_filters_index_analysis` and `input_format_parquet_filter_push_down`; no new
setting. A file whose row groups were skipped writes no query condition cache entry (plain and TopK
keys), because the skipped row groups may still match the cached predicate. The per-file copies of
`FormatFilterInfo` carry the filters only where the reader uses the current column names: not under a
schema transform, where a current name can denote another column of the old file, and not with the
`rows_to_read` of lazy materialization. The per-file count cache needs no guard: a count of an Iceberg
table never reads it back.

New profile event `ParquetRuntimeFilterPrunedRowGroups`. Test
`05457_iceberg_join_runtime_filter_row_group_pruning`: one data file of 16 row groups.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ere skipped

A read that skipped row groups by a JOIN runtime filter counts only the rows it decoded, and the per-file
row count cache is shared with `s3()` reads of the same object, so such a read must not record its count.

Test case Q2 (`IcebergS3`); an Iceberg copy of `orders` (one data file, 20 row groups) and one query in
`join_runtime_filter.xml`.

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

groeneai commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review (2 rounds, nothing open)
Finding Verdict
⚠️ A read whose row groups the runtime filter skipped could cache the row count of the kept row groups as the file's count (per-file count cache, shared with s3()). AGREE, fixed: such a file writes no row count; regression case Q2 (IcebergS3).
⚠️ No CI performance query exercised row-group skipping (the Iceberg suite has one row group per file). AGREE, fixed: join_runtime_filter.xml reads a one-file, 20-row-group Iceberg copy of orders.
💡 The TopK cache guard cannot fire today (TopK cache keys are dropped under a runtime filter at planning). Noted, kept for symmetry.
💡 The new perf query is short (~12-27 ms locally). Noted: the 2x change should clear the threshold.

@groeneai

groeneai commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. 05457_iceberg_join_runtime_filter_row_group_pruning (one data file, 16 row groups) prints ParquetRuntimeFilterPrunedRowGroups: 0 on the base commit in every case, 15 with the change, on every run.
b Root cause explained? The only statistics-based row-group pruning input of the Parquet reader is the key condition built from the planning-time filter, which never contains the JOIN runtime filter, so every row group of a file that survives file pruning was decoded.
c Fix matches root cause? Yes. The built runtime filters become a KeyCondition (the IN set or range MergeTree uses) checked against row-group statistics next to the existing key condition.
d Test intent preserved / new tests added? New test with 13 cases plus a layout check; mutating the skip, either cache guard, the schema-transform rule or the position-delete copy each turns it red (the query condition cache and schema-transform mutants return wrong rows; the row count cache mutant records 100 rows for a 1600-row file).
e Both directions demonstrated? Yes: red on the base commit, green with the change, 50/50 randomized runs.
f Fix is general across code paths? Every cache that learns from a read (query condition cache, TopK entries, the per-file row count shared with s3()) skips a pruned file; the input format wrapper forwards the flag; the per-file filter copies carry the filters only under current column names.
g Fix generalizes across inputs (params/datatypes/wrappers)? Exact set, range, Nullable key, key under one cast, two casts (not pruned), LEFT ANTI (not pruned), preserve_order, an extra query filter, a renamed column, position deletes. Float keys decline as in #128145.
h Backward compatible? (maintainer-approved exception only) Yes. No new setting and no cache-key change; use_join_runtime_filters_for_iceberg_pruning = 0 or input_format_parquet_filter_push_down = 0 turns it off.
i Invariants and contracts preserved? A row group is skipped only if none of its rows can pass every runtime filter; the kept-statistics order is unchanged (the skip comes after the ranges are recorded); the condition is built once per filter info under a mutex and shared read-only.

Session id: cron:clickhouse-impl-slot-5:20261106-100900

@groeneai

groeneai commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator Author

cc @grantholly-clickhouse @kssenii, could you review this and add the can be tested label so CI runs? Once the hash JOIN runtime filters are built, the Parquet reader of an Iceberg read turns them into a KeyCondition and skips the row groups whose min/max statistics cannot match it, on top of the data-file skipping of #128145 (the new code is the last two commits).

@clickhouse-gh

clickhouse-gh Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [8dc31eb]

Summary: ✅


AI Review

Summary

Extends Iceberg JOIN runtime-filter pruning to Parquet row groups, shares the predicate with file pruning, and prevents pruned reads from populating incompatible cache entries. No actionable findings remain at 8dc31ebb96a388cec7c5da1d6e02900a98258d22. The previous benchmark-location finding is fixed, and its thread has been resolved.

Missing context / blind spots
  • ⚠️ No local ClickHouse binary or build was available, so regression tests and benchmarks were not rerun. Runtime evidence comes from the regression coverage and before/after measurements reported in the PR and linked discussion.
Final Verdict

Status: ✅ Approve.

@clickhouse-gh clickhouse-gh Bot added the pr-performance Pull request with some performance improvements label Nov 6, 2026
@clickhouse-gh clickhouse-gh Bot added can be tested Allows running workflows for external contributors comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. labels Nov 6, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 8dc31ebb9 with master f9e6c60e7 (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.

Slowest function optimization changes (ThinLTO)

Median per-function time ratio to the master baseline: programs/clickhouse ×0.76, programs/clickhouse-keeper ×0.68 (each binary is linked separately, on a different machine and with different build flags); deltas below are relative to it.

Binary Function Master PR Δ vs median
programs/clickhouse DB::registerFunctionConversion(DB::FunctionFactory&) 6.8 s 12.8 s +7.7 s (+149%)
programs/clickhouse _ZN6detail10static_forITk7is_enumN2DB23AttributeUnderlyingTypeEZNS1_29callOnDictionaryAttributeType… 3.9 s 8.9 s +5.9 s (+199%)
Compile time of recompiled translation units

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

Job report

@groeneai

groeneai commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 7d36e15

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
Stress test (amd_debug) / Logical error: Cannot write to canceled buffer (STID: 4158-351e) LOGICAL_ERROR, not in this PR's diff (this PR changes Iceberg/Parquet row-group pruning): the embedded client (web terminal) finalizes its JSON output format into its already canceled output buffer in ClientBase::resetOutput (JSONUtils::writeArrayEnd); the same signature appeared on master and on 4 other unrelated PRs in the last 30 days #126142 (mine, open)
Mergeable Check / PR praktika rollups of the row above #126142 (mine, open)
Sync - CH Inc sync (private, not actionable by me)

The Config Workflow / Pre Hooks failure in CIDB comes from the run before the can be tested label was added. CIDB has no other FAIL or ERROR row on this head.

Session id: cron:our-pr-ci-monitor:20261106-173005

@murphy-4o murphy-4o self-assigned this Nov 8, 2026
murphy-4o and others added 5 commits November 11, 2026 12:39
…-row-group-pruning

# Conflicts:
#	src/Processors/Formats/Impl/Parquet/Reader.cpp
#	src/Processors/QueryPlan/ReadFromObjectStorageStep.cpp
#	src/Processors/QueryPlan/RuntimeFilterLookup.h
…and Parquet row groups

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added comp-parquet-reader-v3 Issues related to the native Parquet reader. and removed comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. labels Nov 11, 2026
@murphy-4o

Copy link
Copy Markdown
Member

@groeneai, please investigate the CI failures in this PR (commit 8dc31eb) and fix them, or link existing fixes.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=129717&sha=8dc31ebb96a388cec7c5da1d6e02900a98258d22&name_0=PR

Also, 2 failures in the private sync PR.

@murphy-4o
murphy-4o added this pull request to the merge queue Nov 12, 2026
Merged via the queue into ClickHouse:master with commit eddd66d Nov 12, 2026
187 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 12, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

Public CI on 8dc31eb has no failures: 125 checks passed, 59 skipped, Mergeable Check is green, and CIDB has 0 FAIL/ERROR rows for that commit. The merge-queue run on eddd66d was clean too, and since the merge 05457_iceberg_join_runtime_filter_row_group_pruning has passed all 407 master runs.

I have no access to the private sync PR, so I can't see its 2 failures. If either one is in 05457_iceberg_join_runtime_filter_row_group_pruning or tests/performance/join_runtime_filter.xml, please paste the test name and the error here and I'll fix it in a follow-up PR.

PedroTadim pushed a commit to hsusul/ClickHouse that referenced this pull request Nov 13, 2026
The row groups of an Iceberg data file are skipped by a finished JOIN runtime
filter since ClickHouse#129717, but inside a row group that is kept every page of every
read column was still decoded: page pruning (`applyColumnIndex`) only received
the single-column conditions of the query's own filter and of spatial
predicates, never of the runtime `KeyCondition`.

Give the page index the single-column conditions of the same runtime
`KeyCondition`, appended after the static and spatial ones, the way spatial
conditions are added. A page counts as pruned by the runtime filter only when
the first condition that rules it out is a runtime one, i.e. every other
condition of the column passed (the same rule as for row groups). The counter
is atomic because `applyColumnIndex` runs concurrently for different row groups
and columns, and `isJoinRuntimeFilterApplied` now also reports pruned pages, so
a read that skipped pages writes neither a query condition cache entry (a row
group whose pages were all skipped would be cached as unmatched) nor a cached
row count. Malformed page statistics of a column that only runtime conditions
use do not fail the read; the column is just not pruned, as for its row group
statistics. No new setting; `input_format_parquet_page_filter_push_down`
disables it.

New profile event `ParquetRuntimeFilterPrunedPages`. Test
05457_iceberg_join_runtime_filter_page_pruning, and one query on a file with
20,000-row pages in join_runtime_filter.xml.

Related: ClickHouse#128108

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added comp-iceberg Apache Iceberg tables: reading and writing Iceberg metadata (snapshots, manifests, schema evoluti... and removed comp-parquet-reader-v3 Issues related to the native Parquet reader. labels Nov 22, 2026
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-performance Pull request with some performance improvements 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.

3 participants