alamb commented on code in PR #3905:
URL: https://github.com/apache/arrow-datafusion/pull/3905#discussion_r1000961623
##########
datafusion/core/src/dataframe.rs:
##########
@@ -1349,6 +1358,34 @@ mod tests {
Ok(())
}
+ #[tokio::test]
+ async fn filter_pushdown_dataframe() -> Result<()> {
+ let ctx = SessionContext::new();
+
+ ctx.register_parquet(
+ "test",
+ &format!("{}/alltypes_plain.snappy.parquet", parquet_test_data()),
+ ParquetReadOptions::default(),
+ )
+ .await?;
+
+ ctx.register_table("t1", ctx.table("test")?)?;
+
+ let df = ctx
+ .table("t1")?
+ .filter(col("id").eq(lit(1)))?
+ .select_columns(&["bool_col", "int_col"])?;
+
+ let plan = df.explain(false, false)?.collect().await?;
+ // Filters all the way to Parquet
Review Comment:
🎉
##########
datafusion/core/src/dataframe.rs:
##########
@@ -773,6 +773,14 @@ impl TableProvider for DataFrame {
self
}
+ fn supports_filter_pushdown(
+ &self,
+ _filter: &Expr,
+ ) -> Result<TableProviderFilterPushDown> {
+ // A filter is added on the DataFrame when given
Review Comment:
👍
##########
datafusion/core/src/datasource/view.rs:
##########
@@ -114,20 +122,35 @@ impl TableProvider for ViewTable {
)
})
.collect();
- let plan = LogicalPlanBuilder::from(self.logical_plan.clone())
+ LogicalPlanBuilder::from(self.logical_plan.clone())
.project(fields)?
- .build()?;
- state_cloned.create_physical_plan(&plan).await
+ .build()?
}
} else {
- state_cloned.create_physical_plan(&self.logical_plan).await
+ self.logical_plan().clone()
+ };
+ let mut plan = LogicalPlanBuilder::from(plan);
+ let filter = filters.iter().cloned().reduce(|acc, new| acc.and(new));
Review Comment:
You could use `conjunction` here and above too if you wanted :
https://github.com/apache/arrow-datafusion/blob/master/datafusion/optimizer/src/utils.rs#L123-L147
it just does the same thing, so I don't feel strongly
--
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]