You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/10/20 14:39:36 UTC

[GitHub] [arrow-datafusion] Dandandan opened a new pull request, #3905: Support filter pushdown for views/dataframes

Dandandan opened a new pull request, #3905:
URL: https://github.com/apache/arrow-datafusion/pull/3905

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Closes #3681
   Closes #3249
   
    # Rationale for this change
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   
   # What changes are included in this PR?
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   # Are there any user-facing changes?
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] Dandandan merged pull request #3905: Support filter/limit pushdown for views/dataframes

Posted by GitBox <gi...@apache.org>.
Dandandan merged PR #3905:
URL: https://github.com/apache/arrow-datafusion/pull/3905


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #3905: Support filter/limit pushdown for views/dataframes

Posted by GitBox <gi...@apache.org>.
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org