Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeltaTable DataFusion TableProvider does not support filter pushdown #1064

Closed
alexwilcoxson-rel opened this issue Jan 13, 2023 · 2 comments · Fixed by #1071
Closed

DeltaTable DataFusion TableProvider does not support filter pushdown #1064

alexwilcoxson-rel opened this issue Jan 13, 2023 · 2 comments · Fixed by #1071
Labels
bug Something isn't working

Comments

@alexwilcoxson-rel
Copy link
Contributor

Environment

Delta-rs version: 0.6

Binding: Rust

Environment:

  • Cloud provider: Azure
  • OS: macOS
  • Other: M1

Bug

What happened:
When executing a DataFusion SQL/DataFrame with DeltaTable TableProvider, filters are not pushed down into DeltaTable scan.

What you expected to happen:
Filter pushdown to be supported on DeltaTable so files can be pruned (see related issue #1063)

How to reproduce it:
Run the following snippet with attached table data.zip

    let table = Arc::new(open_table("./data/table").await?);
    let ctx = SessionContext::new();
    let df = ctx.read_table(table)?;
    let df = df.filter(col("n").eq(lit(1 as i64)))?;
    let logical_plan = df.to_logical_plan()?;
    println!("{:?}", logical_plan);

Notice the TableScan has no filters and thus no pruning will occur. If you explain or show the physical plan you'll see the full list of parquet files.

Filter: ?table?.n = Int64(1)
  TableScan: ?table? projection=[n]

More details:
When adding this to the TableProvider impl for DeltaTable

    fn supports_filter_pushdown(
        &self,
        _filter: &Expr,
    ) -> DataFusionResult<TableProviderFilterPushDown> {
        Ok(TableProviderFilterPushDown::Inexact)
    }

the logical plan is

Filter: ?table?.n = Int64(1)
  TableScan: ?table? projection=[n], partial_filters=[?table?.n = Int64(1)]

In conjunction with a fix for #1063 I get proper pruning of files based on statistics in the delta log.

@alexwilcoxson-rel alexwilcoxson-rel added the bug Something isn't working label Jan 13, 2023
@houqp
Copy link
Member

houqp commented Jan 15, 2023

Good catch, do you mind sending a PR combining fixes from both issues?

@alexwilcoxson-rel
Copy link
Contributor Author

Thanks @roeap for including these fixes. Looks good on my end!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants