Skip to content

feat: keep pushed filters on Iceberg data sources - #2

Closed
Perseus wants to merge 1 commit into
iceberg-dyn-filter/d1-predicate-converterfrom
iceberg-dyn-filter/d2-keep-pushed-filters
Closed

Perseus wants to merge 1 commit into
iceberg-dyn-filter/d1-predicate-converterfrom
iceberg-dyn-filter/d2-keep-pushed-filters

Conversation

@Perseus

@Perseus Perseus commented Oct 30, 2026

Copy link
Copy Markdown
Owner

Builds on #1 (predicate converter); review that first.

What and why

Iceberg scans threw away every filter pushed down to them. try_pushdown_filters on LazyIcebergDataSource and EagerIcebergDataSource answered PushedDown::No and did not store anything. As a result, dynamic filters (for example a hash join's build-side bounds) could never reach the Iceberg reader, so there was nothing to prune files with later.

This PR makes both sources keep the filters pushed to them. It does not change what gets read.

How it works

  • Each source has a new field, filters: Vec<Arc<dyn PhysicalExpr>>. try_pushdown_filters appends the incoming filters to any it already holds and returns the updated source with FilterPushdownPropagation::with_updated_node. This is the same pattern DataFusion's ParquetSource uses.
  • The filters are stored as the same Arcs DataFusion passes in. They are not copied, so a DynamicFilterPhysicalExpr that gets updated during execution stays visible through the source.
  • The filters use the source's output schema: column indices match the columns the scan emits. Neither source accepts projection swaps (try_swapping_with_projection returns None), so that schema doesn't change after pushdown.
  • Every filter is still reported as PushedDown::No. The FilterExec above the scan stays in the plan and keeps results exact. Nothing uses the kept filters for reading yet.
  • apply_expressions now visits the kept filters, like other DataFusion sources do with their predicates.
  • Every way the sources are cloned or rebuilt inside the crate (with_fetch, with_file_groups, and so on) keeps the filters, because those paths clone the source. The constructors in table_provider/scan.rs and from_file_groups start with an empty list.
  • EXPLAIN shows the kept filters ANDed into one expression (via conjunction, so brackets are correct), and shows nothing when there are none:
    • eager: predicate=..., matching how DataFusion's DataSourceExec shows predicates and dynamic filters;
    • lazy: physical_predicate=..., because the lazy scan already prints predicate= for its Iceberg-side predicate, and two keys with the same name would be confusing.
  • The codecs do not carry the filters yet. The lazy codec just starts the new field as an empty list, so filters are dropped when a plan is sent to a worker. Follow-up PRs will send the filters to workers (keeping dynamic-filter updates) and then use them to prune files when they are opened.

Tests

  • New iceberg/tests/kept_filters.rs has four named tests that run the normal planning path through IcebergTestHarness on the taxi fixture:
    • lazy_scan_keeps_static_filter and eager_scan_keeps_static_filter: the scan shows the kept filter, the FilterExec is still present, and the count is unchanged.
    • lazy_scan_keeps_hash_join_dynamic_filter and eager_scan_keeps_hash_join_dynamic_filter: the probe-side scan shows DynamicFilter [ ... ], and the join result is correct.
  • Existing snapshots in filter_pushdown.rs, limit_pushdown.rs and projection_pushdown.rs change only to add the new physical_predicate= text. Results are unchanged.
  • Checks run: cargo fmt --all, cargo clippy -p datafusion-distributed-iceberg --all-targets (no new warnings), cargo test -p datafusion-distributed-iceberg (all pass).

Lazy and eager Iceberg sources now store the filters pushed to them
(static and dynamic) and show them in EXPLAIN, while still reporting
PushedDown::No so the parent FilterExec keeps results exact.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant