Perseus opened a new issue, #144: URL: https://github.com/apache/datafusion-iceberg/issues/144
## Problem DataFusion builds filters while a query runs: * a hash join builds one from the keys on its build side * a sort with a limit (TopK) builds one from the rows it has kept so far * a min() or max() with no GROUP BY builds one from the value it has found so far These filters can help reduce the amount of data being scanned and improve performance. The Iceberg scanning in `datafusion-iceberg` doesn't currently use these filters. [Relevant blog](https://datafusion.apache.org/blog/2025/09/10/dynamic-filters/) ## Goal Add support for applying filters discovered during execution (aka dynamic or runtime filters) to the Iceberg scans. These can be used to prune data during execution, and can improve query performance. This issue tracks the work in datafusion-iceberg and any iceberg-rust changes it depends on. **Feedback on the plan is very welcome.** ## How it works There are two points in the query execution flow where dynamic filters can be used - ### Before file planning If filters become available *before* files are planned, we can provide the new predicates to `iceberg-rust` and it can exclude any manifests/data files that would be filtered out by those predicates, returning a `FileScanTask` stream that only contains files that could have the requested data. This only works with `Lazy` planning. If `Eager` planning is turned on, `FileScanTask`s are created during query planning and no dynamic filters are available yet. It is also useful only for `HashJoin` - by default, a `HashJoin` finishes reading its build side before it reads the probe side, so the dynamic filter built from the build side is available before the probe side starts. However, when join buffering is on (`datafusion.execution.hash_join_buffering_capacity` > 0), the probe side can buffer-ahead and start reading data before dynamic filters are built. TopK and min/max filters are only built from the actual rows being read, so they are not available at planning time. ### After file planning As filters become available, we can skip or modify `FileScanTask`s to apply those filters, resulting in multiple levels of data pruning (detailed in the work items below) This is useful for joins, TopK and min/max aggregates, and will work for both `Lazy` and `Eager` execution modes. The flow for this would look something like this - ```mermaid flowchart LR A["Dynamic filters"] A -->|"try_pushdown_filters"| B["Iceberg scan<br/>stores them"] B --> C["Before each<br/>file opens"] C -->|"partition<br/>can't match"| S["Skip the file"] C -->|"min/max<br/>can't match"| S C -->|"otherwise"| D["Append filter to the<br/>task's predicate"] D --> E["ArrowReader <br />skips row groups, <br/> pages and rows"] ``` ## Work _Last updated Nov 30, 2026_ The work listed below is not exhaustive - there might be changes based on information gathered during implementation or based on feedback. ### Converter and plumbing - [ ] Accept and store the filters DF pushes in `IcebergDataSource::try_pushdown_filters`, and report them from `apply_expressions`. Continue to return `PushedDown::No` from `try_pushdown_filters` so that DF keeps checking every row itself - [ ] #106 - `PhysicalExpr` → `iceberg::Predicate` converter. Dynamic filters are provided as `PhysicalExpr`s and need to be converted into `iceberg::Predicate`s so that they can be used by iceberg-rust to prune data - [ ] Convert dynamic filters to `iceberg::Predicate` and cache them, re-evaluating when the snapshot generation changes ### Skip files while listing (lazy planning) - [ ] When a lazy scan starts listing files, add the dynamic filter to the predicate and build the `TableScan` with it ### Skip whole files - [ ] **By partition value** - skip `FileScanTask`s using any filters on columns that are part of the partitioning spec. This is possible today, but would be made a lot simpler with https://github.com/apache/iceberg-rust/issues/3675 - [ ] **By column min and max** - skip `FileScanTask`s using the per-task stats from apache/iceberg-rust#3424 and the values from the dynamic filters. For this, we can either use DF's `PruningPredicate` or ask for `iceberg-rust` to expose their internal evaluation logic as a public API ### Skip row groups and pages - [ ] `AND` the filter onto each task's predicate when the reader picks up the task. `iceberg-rust` currently doesn't allow changing a task's predicate, so we must re-create the task with the new one. - [ ] iceberg-rust: an API that lets the `ArrowReader` read runtime filters itself as it starts each file, like apache/iceberg-rust#3351. It removes the task rebuild and can be reused by any query engine, so we can remove the workaround once there's agreement from the `iceberg-rust` community. iceberg-rust's `ArrowReader` skips row groups and pages using the predicate provided to a `FileScanTask`. It also builds a row filter from that predicate + equality deletes to filter out deleted rows, so we can't disable it entirely yet. This can have an impact on performance [1] and so this usage of dynamic filters can be default-off behind a setting until `iceberg-rust` allows configuring the row filter without impacting the delete code path. ### Observability - [ ] Add pruning metrics to `EXPLAIN ANALYZE` plans ### iceberg-rust - [ ] apache/iceberg-rust#3675 - Utilities to make partition-spec-based skipping easier - [ ] apache/iceberg-rust#3739 - Faster `IN (..)` checks in iceberg-rust's reader, for per-row filtering - [ ] Add support for enabling pruning with predicates without enforcing per-row filtering which can have a performance overhead ## Related [1] Performance impact of the row filter when it drops few or no rows - https://github.com/apache/iceberg-rust/issues/3613 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
