Skip to content

feature: exposing utilities for partition-based runtime filtering/pruning #3675

Open

Description

@Perseus

Is your feature request related to a problem or challenge?

iceberg-rust already performs many levels of data pruning - skipping files, row groups etc. The predicates used to do this are collected when a scan is being built, and they remain static through the entire execution pipeline.

Query engines, like DataFusion, can gather information during a query's execution that can be used to further filter out data being scanned from Iceberg (aka dynamic filtering). However, iceberg-rust doesn't yet have a way for the engine to pass in this information at runtime.

Additionally, if an engine plans FileScanTasks up-front, it needs to be able to use information that becomes available as the query runs to skip file scans that are provably useless.

There is some work ongoing here - #3343 , which plans to implement a general runtime/adaptive pruning system. However, the current proposed changes take effect after a file has been opened, while we could use partition-column information to skip files entirely.

Describe the solution you'd like

I would like to propose a smaller set of changes that allow consumers of the library to use the partition pruning logic that is currently private. This would allow dropping a FileScanTask based on predicates that became available during query execution.

Approach 1

Make ExpressionEvaluator and InclusiveProjection public. These provide the building blocks that engines can use to implement this filtering themselves.

However, these aren't enough on their own; callers would also need to build the partition schema, handle partition spec changes etc. This would also tie callers to iceberg-rust internals that may change over time.

There is a draft PR here in DataFusion Distributed that reimplements these pieces today.

Approach 2

Create a public PartitionFilter utility which performs the same work - evaluates whether a FileScanTask can be skipped based on the given predicate - but has its internals abstracted away from the user.

The API could be something like -

 let filter = PartitionFilter::try_new(predicate, task.schema_ref(), spec, task.case_sensitive())?;
 if !filter.can_match(partition)? {
   // skip the task
 }

I have a draft version of this approach here - the set of changes are fairly small; if the structure looks acceptable, I can iterate on it to make it suitable for a review and merging it in.

There might be other approaches that I am missing due to lack of context, and I'm happy to pursue any path that the maintainers feel comfortable with - the goal is to make it possible for query engines to make scan decisions at runtime

Willingness to contribute

I would be willing to contribute to this feature with guidance from the Iceberg Rust community

Activity

  1. added
    enhancement
    on Nov 11, 2026
  2. changed the title [-]feature: exposing utilities for runtime filtering/pruning[/-] [+]feature: exposing utilities for partition-based runtime filtering/pruning[/+] on Nov 11, 2026
  3. Perseus commented on Nov 12, 2026

    @Perseus
    Author

    Some more context from other libraries/query engines

    The Java library (https://github.com/apache/iceberg) exposes all the functions required to do the partition evaluation -

    • Evaluator (equivalent to ExpressionEvaluator in iceberg-rust)
    • Projection (contains InclusiveProjection equivalent for iceberg-rust)

    Engines like Spark that plan the scan tasks eagerly use these APIs to perform runtime filtering for partitions

  4. nevzheng commented on Nov 12, 2026

    @nevzheng

    Thanks for writing this up, @Perseus, and for the draft in #3674.

    The use case makes sense to me: engines learn things during execution (e.g. DataFusion dynamic filters from a join build side) that could prune whole files by partition, and today there's no supported way to do that without reimplementing internals, as the DataFusion Distributed draft shows.

    High level: From my perspective, this feels like a new public API for iceberg-rust, so it seems worth taking extra care in how it's designed and maintained. For that reason I lean toward Approach 2: a small, deliberate surface rather than making ExpressionEvaluator / InclusiveProjection public. I'm not sure if those were intended as public contracts, and exposing them would push partition-schema construction and spec evolution onto callers and lock in internals that may need to change.

    A possible way to approach it:

    1. Start with the minimal subset this use case needs: given a predicate, decide whether a FileScanTask can be skipped based on its partition values. Define that well and keep the rest internal.
    2. Align on scope before expanding. In the community sync, Matt raised questions about which kinds of operations/predicates this should support. A short scope doc (what's in v1, what's deliberately out) might help settle that up front rather than in PR review, though I'll defer to the maintainers on whether that's needed.
    3. Treat extensions as follow-ups: e.g. more predicate types, row-group or metrics-based pruning, or a built-in runtime-filter hook in the scan itself. As use cases emerge etc.

    Things a scope doc could cover:

    Details
    • Use cases / CUJs: the concrete callers this needs to serve (e.g. DataFusion dynamic filters, DataFusion Distributed, eager-planning engines similar to Spark's use of Java's Evaluator/Projection), and which are in scope for v1 vs. later.
    • API details:
      • Semantics/naming: inclusive projection answers "might match", so false is safe to skip on and true means "maybe". Something like might_match could make that conservative contract more explicit.
      • Construction cost: projection is per partition spec, not per task. Building the filter once per scan (predicate + schema + case sensitivity) and caching projections by spec_id internally could help, and would also hide spec evolution from callers.
      • Signatures: taking things callers already have (unbound Predicate, FileScanTask) would keep internal types out of the public surface.
      • Edge cases: predicates on non-partition columns, non-projectable transforms, unknown specs. My instinct is that these should degrade to "don't skip" rather than erroring.
    • Test plan / validation: the key invariant is no false negatives (never skip a file that could contain matching rows). Coverage across transforms (identity, bucket, truncate, year/month/day/hour, void), tables with multiple partition specs, null partition values, and case sensitivity seems important. Possibly also parity checks against Java's Evaluator behavior, plus an end-to-end test showing files actually get skipped in an engine integration.
    • Maintainers / ownership: who reviews and owns this surface going forward, since it'll be a contract downstream engines depend on.
    • Evolution: how it can grow without breaking callers (e.g. #[non_exhaustive], builder-style construction, possibly marking it experimental at first), and how it relates to a future built-in runtime-filter hook. Ideally iceberg-rust's own planning uses the same code path, so the API stays well tested.

    Happy to help review as this evolves. Thanks for driving it!

    Looking forward to any maintainers thoughts on this.

    cc: @mbutrovich

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    datafusionenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions