[SPARK-58199][SQL] Add FileIndex fullyPushedFilter hint for physical plan#57340
Open
szehon-ho wants to merge 1 commit into
Open
[SPARK-58199][SQL] Add FileIndex fullyPushedFilter hint for physical plan#57340szehon-ho wants to merge 1 commit into
szehon-ho wants to merge 1 commit into
Conversation
yyanyy
approved these changes
Jul 17, 2026
| // for removing filters from the row-level FilterExec above the scan. | ||
| val afterScanFilters = fsRelation.location.fullyPushedFilters match { | ||
| case Some(fullyPushedFilters) => filterSet -- fullyPushedFilters | ||
| case None => filterSet -- partitionKeyFilters.filter(_.references.nonEmpty) |
Contributor
There was a problem hiding this comment.
nit/nonblocker - I wonder if we can always set partition key filters in index when we see it the first time to avoid the fallback; is that possible?
Member
Author
There was a problem hiding this comment.
yes, let me address with the other concern (that we dont call listFiles yet until physical execution..)
… plan Add an optional fullyPushedFilters(partitionKeyFilters, dataFilters) method to the FileIndex trait and use it in FileSourceStrategy to determine which filters can be removed from the row-level FilterExec above the scan. The default implementation returns partitionKeyFilters, preserving existing behavior. Co-authored-by: Isaac
szehon-ho
force-pushed
the
SPARK-fileindex-fully-pushed-filters
branch
from
July 17, 2026 21:42
03e3446 to
bec1e80
Compare
yyanyy
approved these changes
Jul 17, 2026
HyukjinKwon
approved these changes
Jul 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
This PR adds an optional
fullyPushedFiltershint to theFileIndextrait andteaches
FileSourceStrategyto use it when deciding which filters can be removedfrom the row-level
FilterExecplaced above the scan.FileIndex.fullyPushedFilters: Option[Seq[Expression]]defaults toNone.FileSourceStrategy, the set of post-scan (after-scan) filters is now computed as:FileIndexreturnsSome(fullyPushedFilters), those filters are theonly basis for removing predicates from the
FilterExecabove the scan(
filterSet -- fullyPushedFilters).None, planning keeps the existing default behavior(
filterSet -- partitionKeyFilters.filter(_.references.nonEmpty)).This lets a
FileIndeximplementation that guarantees certain predicates for allreturned rows (e.g. an index that fully prunes on non-partition columns) tell the
planner exactly which filters are safe to drop, instead of relying only on the
default partition-key heuristic.
Note: in DSV2 , the scalar subquery partition filters are kept on FIlterExec for correctness, but they are removed in DSV1 world.
Why are the changes needed?
Today
FileSourceStrategyassumes only partition-key filters are fully satisfied byfile listing, so any other predicate a
FileIndexmay fully guarantee must still bere-evaluated in a
FilterExec. CustomFileIndeximplementations have no way tocommunicate stronger pushdown guarantees to the physical plan. The new hint provides
an opt-in mechanism, with no behavior change for existing indexes (default
None).Does this PR introduce any user-facing change?
No. The new trait method has a default implementation returning
None, whichpreserves the existing planning behavior for all built-in
FileIndeximplementations.How was this patch tested?
Added a unit test in
FileSourceStrategySuite("FileIndex fullyPushedFilters controls final FilterExec removal") that exercises a
test
FileIndexreturningNone,Some(Nil), andSome(<data filter>), and assertsthe resulting
FilterExecpredicates. Ran:All tests passed.
Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 4.8)