Skip to content

Spark 4.2: Drop dynamic pruning filters that nest pruning filters - #49

Merged
robert3005 merged 1 commit into
mainfrom
rk/spark-nested-dynamic-pruning
Nov 25, 2026
Merged

robert3005 merged 1 commit into
mainfrom
rk/spark-nested-dynamic-pruning

Conversation

@robert3005

Copy link
Copy Markdown

Summary

  • Add the optimizer rule NestedDynamicPruning, which drops each dynamic pruning filter whose filtering plan holds pruning filters of its own. The Iceberg session extensions install it.
  • Without the rule, a common table expression that joins with itself makes the plan grow by a factor of three per level of joins. The test query has five levels on a partition column: 121 pruning filters without the rule, and 2 with it.
  • This is the rule from Spark 4.2, Vortex: faster scans of Vortex tables #48, taken out so that it can merge by itself. It does not depend on runtime filters for data columns.

Checks

  • TestNestedDynamicPruning passes on Spark 4.2 (8 tests). Without the rule, the plan of the test query has 121 pruning filters, which is above the limit of 20 in the test.
  • spotlessApply on the two Spark 4.2 modules.
  • Not run: the full Spark test suites, and the other Spark versions. No backports are in this PR.

🤖 Generated with Claude Code

https://claude.ai/code/session_018SWbEtEQLKKebxSCarAZrU

Spark adds one pruning subquery per join that can prune a scan, holding
the plan of the join's other side. When a common table expression joins
with itself, each subquery copies the subqueries of that side, and the
plan grows by a factor of three per level of joins: five levels on a
partition column give 121 pruning filters.

The Iceberg session extensions now install NestedDynamicPruning, which
drops each pruning filter whose filtering plan holds pruning filters of
its own. A pruning filter only skips rows that the join drops, so the
result does not change.

Signed-off-by: Robert Kruszewski <github@robertk.io>
@github-actions github-actions Bot added the SPARK label Nov 18, 2026
@robert3005
robert3005 merged commit 4c95df5 into main Nov 25, 2026
35 of 40 checks passed
@robert3005
robert3005 deleted the rk/spark-nested-dynamic-pruning branch November 25, 2026 09:37
robert3005 added a commit that referenced this pull request Nov 25, 2026
Main gained the NestedDynamicPruning rule (#49), which this branch
already has. The rule keeps the branch's comments, because here it also
lets scans offer data columns to dynamic pruning. The test keeps both
cases: the partition column test from main and the data column test
from this branch.

Generated-by: Claude Code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant