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/12/01 01:01:39 UTC

[GitHub] [arrow-datafusion] jackwener opened a new pull request, #4447: fix `push_down_filter` push `Expr` instead of `column`.

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

   # 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 #4401.
   
   # 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 these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   
   # 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] mingmwang commented on a diff in pull request #4447: fix `push_down_filter` push `Expr` instead of `column`.

Posted by GitBox <gi...@apache.org>.
mingmwang commented on code in PR #4447:
URL: https://github.com/apache/arrow-datafusion/pull/4447#discussion_r1036657546


##########
datafusion/optimizer/src/push_down_filter.rs:
##########
@@ -643,18 +643,25 @@ impl OptimizerRule for PushDownFilter {
                 for expr in predicates {
                     let columns = expr.to_columns()?;
                     if columns.is_empty()
-                        || !columns
-                            .intersection(&used_columns)
-                            .collect::<HashSet<_>>()
-                            .is_empty()
+                        || columns.intersection(&aggr_expr_columns).next().is_some()
                     {
                         keep_predicates.push(expr);
                     } else {
                         push_predicates.push(expr);
                     }
                 }
 
-                let child = match conjunction(push_predicates) {
+                let mut replace_map = HashMap::new();
+                for expr in &agg.group_expr {
+                    replace_map.insert(expr.display_name()?, expr.clone());
+                }
+

Review Comment:
   Could you please add some comments here such as the Aggregate use the group Exprs display name as the schema's Field names. Because this is not that obvious and others might not clear about this 



-- 
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] jackwener commented on a diff in pull request #4447: fix `push_down_filter` push `Expr` instead of `column`.

Posted by GitBox <gi...@apache.org>.
jackwener commented on code in PR #4447:
URL: https://github.com/apache/arrow-datafusion/pull/4447#discussion_r1036707613


##########
datafusion/optimizer/src/push_down_filter.rs:
##########
@@ -910,11 +922,9 @@ mod tests {
         // rewrite to CNF
         // (c = 1 OR c = 1) [can pushDown] AND (c = 1 OR b > 3) AND (b > 2 OR C = 1) AND (b > 2 OR b > 3)
 
-        let expected = "\
-        Filter: (test.c = Int64(1) OR b > Int64(3)) AND (b > Int64(2) OR test.c = Int64(1)) AND (b > Int64(2) OR b > Int64(3))\
+        let expected = "Filter: (test.c = Int64(1) OR test.c = Int64(1)) AND (test.c = Int64(1) OR b > Int64(3)) AND (b > Int64(2) OR test.c = Int64(1)) AND (b > Int64(2) OR b > Int64(3))\
         \n  Aggregate: groupBy=[[test.a]], aggr=[[SUM(test.b) AS b]]\
-        \n    Filter: test.c = Int64(1) OR test.c = Int64(1)\
-        \n      TableScan: test";

Review Comment:
   Original plan is wrong.😂
   I think we need to delete this wrong UT.
   
   Filter include column that not in output of Aggregate.



-- 
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] jackwener commented on a diff in pull request #4447: fix `push_down_filter` push `Expr` instead of `column`.

Posted by GitBox <gi...@apache.org>.
jackwener commented on code in PR #4447:
URL: https://github.com/apache/arrow-datafusion/pull/4447#discussion_r1036707613


##########
datafusion/optimizer/src/push_down_filter.rs:
##########
@@ -910,11 +922,9 @@ mod tests {
         // rewrite to CNF
         // (c = 1 OR c = 1) [can pushDown] AND (c = 1 OR b > 3) AND (b > 2 OR C = 1) AND (b > 2 OR b > 3)
 
-        let expected = "\
-        Filter: (test.c = Int64(1) OR b > Int64(3)) AND (b > Int64(2) OR test.c = Int64(1)) AND (b > Int64(2) OR b > Int64(3))\
+        let expected = "Filter: (test.c = Int64(1) OR test.c = Int64(1)) AND (test.c = Int64(1) OR b > Int64(3)) AND (b > Int64(2) OR test.c = Int64(1)) AND (b > Int64(2) OR b > Int64(3))\
         \n  Aggregate: groupBy=[[test.a]], aggr=[[SUM(test.b) AS b]]\
-        \n    Filter: test.c = Int64(1) OR test.c = Int64(1)\
-        \n      TableScan: test";

Review Comment:
   Original plan is wrong.😂
   I think we need to delete this wrong UT.



-- 
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] mingmwang commented on a diff in pull request #4447: fix `push_down_filter` push `Expr` instead of `column`.

Posted by GitBox <gi...@apache.org>.
mingmwang commented on code in PR #4447:
URL: https://github.com/apache/arrow-datafusion/pull/4447#discussion_r1036654944


##########
datafusion/optimizer/src/push_down_filter.rs:
##########
@@ -643,18 +643,25 @@ impl OptimizerRule for PushDownFilter {
                 for expr in predicates {
                     let columns = expr.to_columns()?;
                     if columns.is_empty()
-                        || !columns
-                            .intersection(&used_columns)
-                            .collect::<HashSet<_>>()
-                            .is_empty()

Review Comment:
   The logic should check all the columns used by the Filter predicate is the subset of the group by Exprs output Columns.  



-- 
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] jackwener commented on a diff in pull request #4447: fix `push_down_filter` push `Expr` instead of `column`.

Posted by GitBox <gi...@apache.org>.
jackwener commented on code in PR #4447:
URL: https://github.com/apache/arrow-datafusion/pull/4447#discussion_r1036594951


##########
datafusion/optimizer/src/push_down_filter.rs:
##########
@@ -643,18 +643,25 @@ impl OptimizerRule for PushDownFilter {
                 for expr in predicates {
                     let columns = expr.to_columns()?;
                     if columns.is_empty()
-                        || !columns
-                            .intersection(&used_columns)
-                            .collect::<HashSet<_>>()
-                            .is_empty()

Review Comment:
   The original performance was bad



-- 
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] mingmwang commented on pull request #4447: fix `push_down_filter` push `Expr` instead of `column`.

Posted by GitBox <gi...@apache.org>.
mingmwang commented on PR #4447:
URL: https://github.com/apache/arrow-datafusion/pull/4447#issuecomment-1334781946

   LGTM. 


-- 
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 #4447: fix `push_down_filter` push `Expr` instead of `column`.

Posted by GitBox <gi...@apache.org>.
alamb commented on code in PR #4447:
URL: https://github.com/apache/arrow-datafusion/pull/4447#discussion_r1038761919


##########
datafusion/optimizer/src/push_down_filter.rs:
##########
@@ -881,40 +880,30 @@ mod tests {
     }
 
     #[test]
-    fn filter_keep_agg() -> Result<()> {
-        let table_scan = test_table_scan()?;
-        let plan = LogicalPlanBuilder::from(table_scan)
-            .aggregate(vec![col("a")], vec![sum(col("b")).alias("b")])?
-            .filter(col("b").gt(lit(10i64)))?
+    fn push_agg_need_replace_expr() -> Result<()> {
+        let plan = LogicalPlanBuilder::from(test_table_scan()?)
+            .aggregate(vec![add(col("b"), col("a"))], vec![sum(col("a")), col("b")])?
+            .filter(col("test.b + test.a").gt(lit(10i64)))?
             .build()?;
-        // filter of aggregate is after aggregation since they are non-commutative
-        let expected = "\
-            Filter: b > Int64(10)\
-            \n  Aggregate: groupBy=[[test.a]], aggr=[[SUM(test.b) AS b]]\
-            \n    TableScan: test";
+        let expected =
+            "Aggregate: groupBy=[[test.b + test.a]], aggr=[[SUM(test.a), test.b]]\
+        \n  Filter: test.b + test.a > Int64(10)\
+        \n    TableScan: test";
         assert_optimized_plan_eq(&plan, expected)
     }
 
     #[test]
-    fn filter_keep_partial_agg() -> Result<()> {
+    fn filter_keep_agg() -> Result<()> {
         let table_scan = test_table_scan()?;
-        let f1 = col("c").eq(lit(1i64)).and(col("b").gt(lit(2i64)));
-        let f2 = col("c").eq(lit(1i64)).and(col("b").gt(lit(3i64)));
-        let filter = f1.or(f2);
         let plan = LogicalPlanBuilder::from(table_scan)
             .aggregate(vec![col("a")], vec![sum(col("b")).alias("b")])?
-            .filter(filter)?
+            .filter(col("b").gt(lit(10i64)))?
             .build()?;
         // filter of aggregate is after aggregation since they are non-commutative
-        // (c =1 AND b > 2) OR (c = 1 AND b > 3)
-        // rewrite to CNF
-        // (c = 1 OR c = 1) [can pushDown] AND (c = 1 OR b > 3) AND (b > 2 OR C = 1) AND (b > 2 OR b > 3)
-
         let expected = "\
-        Filter: (test.c = Int64(1) OR b > Int64(3)) AND (b > Int64(2) OR test.c = Int64(1)) AND (b > Int64(2) OR b > Int64(3))\
-        \n  Aggregate: groupBy=[[test.a]], aggr=[[SUM(test.b) AS b]]\
-        \n    Filter: test.c = Int64(1) OR test.c = Int64(1)\
-        \n      TableScan: test";
+            Filter: b > Int64(10)\

Review Comment:
   I agree this new plan is correct 



##########
datafusion/optimizer/src/push_down_filter.rs:
##########
@@ -641,20 +633,27 @@ impl OptimizerRule for PushDownFilter {
                 let mut keep_predicates = vec![];
                 let mut push_predicates = vec![];
                 for expr in predicates {
-                    let columns = expr.to_columns()?;
-                    if columns.is_empty()
-                        || !columns
-                            .intersection(&used_columns)
-                            .collect::<HashSet<_>>()
-                            .is_empty()
-                    {
-                        keep_predicates.push(expr);
-                    } else {
+                    let cols = expr.to_columns()?;
+                    if cols.iter().all(|c| group_expr_columns.contains(c)) {
                         push_predicates.push(expr);
+                    } else {
+                        keep_predicates.push(expr);
                     }
                 }
 
-                let child = match conjunction(push_predicates) {
+                // As for plan Filter: Column(a+b) > 0 -- Agg: groupby:[Column(a)+Column(b)]

Review Comment:
   Nice -- this is getting quite sophisticated. 



##########
datafusion/optimizer/src/push_down_filter.rs:
##########
@@ -881,40 +880,30 @@ mod tests {
     }
 
     #[test]
-    fn filter_keep_agg() -> Result<()> {
-        let table_scan = test_table_scan()?;
-        let plan = LogicalPlanBuilder::from(table_scan)
-            .aggregate(vec![col("a")], vec![sum(col("b")).alias("b")])?
-            .filter(col("b").gt(lit(10i64)))?
+    fn push_agg_need_replace_expr() -> Result<()> {
+        let plan = LogicalPlanBuilder::from(test_table_scan()?)
+            .aggregate(vec![add(col("b"), col("a"))], vec![sum(col("a")), col("b")])?
+            .filter(col("test.b + test.a").gt(lit(10i64)))?
             .build()?;
-        // filter of aggregate is after aggregation since they are non-commutative
-        let expected = "\
-            Filter: b > Int64(10)\
-            \n  Aggregate: groupBy=[[test.a]], aggr=[[SUM(test.b) AS b]]\
-            \n    TableScan: test";
+        let expected =
+            "Aggregate: groupBy=[[test.b + test.a]], aggr=[[SUM(test.a), test.b]]\
+        \n  Filter: test.b + test.a > Int64(10)\

Review Comment:
   👍  very nice



##########
datafusion/optimizer/src/push_down_filter.rs:
##########
@@ -641,20 +633,27 @@ impl OptimizerRule for PushDownFilter {
                 let mut keep_predicates = vec![];
                 let mut push_predicates = vec![];
                 for expr in predicates {
-                    let columns = expr.to_columns()?;
-                    if columns.is_empty()
-                        || !columns
-                            .intersection(&used_columns)
-                            .collect::<HashSet<_>>()
-                            .is_empty()
-                    {
-                        keep_predicates.push(expr);
-                    } else {
+                    let cols = expr.to_columns()?;
+                    if cols.iter().all(|c| group_expr_columns.contains(c)) {
                         push_predicates.push(expr);
+                    } else {
+                        keep_predicates.push(expr);
                     }
                 }
 
-                let child = match conjunction(push_predicates) {
+                // As for plan Filter: Column(a+b) > 0 -- Agg: groupby:[Column(a)+Column(b)]
+                // After push, we need to replace `a+b` with Column(a)+Column(b)
+                // So we need create a replace_map, add {`a+b` --> Expr(Column(a)+Column(b))}
+                let mut replace_map = HashMap::new();
+                for expr in &agg.group_expr {
+                    replace_map.insert(expr.display_name()?, expr.clone());

Review Comment:
   Double checked that `display_name` is the right one: https://docs.rs/datafusion/14.0.0/datafusion/prelude/enum.Expr.html#method.display_name 👍 



##########
datafusion/optimizer/tests/integration-test.rs:
##########
@@ -304,6 +304,18 @@ fn join_keys_in_subquery_alias_1() {
     assert_eq!(expected, format!("{:?}", plan));
 }
 
+#[test]
+fn push_down_filter_groupby_expr_contains_alias() {
+    let sql = "SELECT * FROM (SELECT (col_int32 + col_uint32) AS c, count(*) FROM test GROUP BY 1) where c > 3";
+    let plan = test_sql(sql).unwrap();
+    let expected = "Projection: c, COUNT(UInt8(1))\
+    \n  Projection: test.col_int32 + test.col_uint32 AS c, COUNT(UInt8(1))\
+    \n    Aggregate: groupBy=[[test.col_int32 + CAST(test.col_uint32 AS Int32)]], aggr=[[COUNT(UInt8(1))]]\
+    \n      Filter: test.col_int32 + CAST(test.col_uint32 AS Int32) > Int32(3)\

Review Comment:
   👍 



-- 
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] mingmwang commented on a diff in pull request #4447: fix `push_down_filter` push `Expr` instead of `column`.

Posted by GitBox <gi...@apache.org>.
mingmwang commented on code in PR #4447:
URL: https://github.com/apache/arrow-datafusion/pull/4447#discussion_r1036654318


##########
datafusion/optimizer/src/push_down_filter.rs:
##########
@@ -643,18 +643,25 @@ impl OptimizerRule for PushDownFilter {
                 for expr in predicates {
                     let columns = expr.to_columns()?;
                     if columns.is_empty()
-                        || !columns
-                            .intersection(&used_columns)
-                            .collect::<HashSet<_>>()
-                            .is_empty()

Review Comment:
   As I mentioned in the last PR, I think we do not need to check the aggregate Exprs, but just check the group by Exprs. In some cases, the same column can exist in both aggregate Exprs and group by Exprs, for example `select count(distinct col_a),  col_a from table  group by col_a; ` .  If there is a Filter applied to col_a, the Filter can still be pushed down even it is referred  by the agg Exprs.



-- 
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] liukun4515 commented on a diff in pull request #4447: fix `push_down_filter` push `Expr` instead of `column`.

Posted by GitBox <gi...@apache.org>.
liukun4515 commented on code in PR #4447:
URL: https://github.com/apache/arrow-datafusion/pull/4447#discussion_r1036706977


##########
datafusion/optimizer/src/push_down_filter.rs:
##########
@@ -910,11 +922,9 @@ mod tests {
         // rewrite to CNF
         // (c = 1 OR c = 1) [can pushDown] AND (c = 1 OR b > 3) AND (b > 2 OR C = 1) AND (b > 2 OR b > 3)
 
-        let expected = "\
-        Filter: (test.c = Int64(1) OR b > Int64(3)) AND (b > Int64(2) OR test.c = Int64(1)) AND (b > Int64(2) OR b > Int64(3))\
+        let expected = "Filter: (test.c = Int64(1) OR test.c = Int64(1)) AND (test.c = Int64(1) OR b > Int64(3)) AND (b > Int64(2) OR test.c = Int64(1)) AND (b > Int64(2) OR b > Int64(3))\

Review Comment:
   cc @Ted-Jiang 



-- 
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] ursabot commented on pull request #4447: fix `push_down_filter` for pushing filters on grouping columns rather than aggregate columns

Posted by GitBox <gi...@apache.org>.
ursabot commented on PR #4447:
URL: https://github.com/apache/arrow-datafusion/pull/4447#issuecomment-1336133662

   Benchmark runs are scheduled for baseline = 8db99d24661e981002e9f6a5532358689200ae5f and contender = 05096924218782c75bbe1c37b22765f6afb5a63e. 05096924218782c75bbe1c37b22765f6afb5a63e is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
   Conbench compare runs links:
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ec2-t3-xlarge-us-east-2] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/25d3e97e67364da6b7f04d05aea5b7d4...c655fc6995d847fb911ed1c9e8760577/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on test-mac-arm] [test-mac-arm](https://conbench.ursa.dev/compare/runs/f148f80b4e114c84b95568963bb968dc...db8eb78fdb354a3287825c5738109fc0/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ursa-i9-9960x] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/adeabedc03654456a7a5c8d3f9c2f891...9396a9357b904a7db782e23512ced89e/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ursa-thinkcentre-m75q] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/5b7bf2c8d7df4880adea00c587760aaf...90e853c7e13948f390d7bc5c3efe00c2/)
   Buildkite builds:
   Supported benchmarks:
   ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
   test-mac-arm: Supported benchmark langs: C++, Python, R
   ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
   ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
   


-- 
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] jackwener commented on pull request #4447: fix `push_down_filter` push `Expr` instead of `column`.

Posted by GitBox <gi...@apache.org>.
jackwener commented on PR #4447:
URL: https://github.com/apache/arrow-datafusion/pull/4447#issuecomment-1336001356

   @alamb PTAL @Dandandan 


-- 
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] Ted-Jiang commented on a diff in pull request #4447: fix `push_down_filter` push `Expr` instead of `column`.

Posted by GitBox <gi...@apache.org>.
Ted-Jiang commented on code in PR #4447:
URL: https://github.com/apache/arrow-datafusion/pull/4447#discussion_r1036727421


##########
datafusion/optimizer/src/push_down_filter.rs:
##########
@@ -910,11 +922,9 @@ mod tests {
         // rewrite to CNF
         // (c = 1 OR c = 1) [can pushDown] AND (c = 1 OR b > 3) AND (b > 2 OR C = 1) AND (b > 2 OR b > 3)
 
-        let expected = "\
-        Filter: (test.c = Int64(1) OR b > Int64(3)) AND (b > Int64(2) OR test.c = Int64(1)) AND (b > Int64(2) OR b > Int64(3))\
+        let expected = "Filter: (test.c = Int64(1) OR test.c = Int64(1)) AND (test.c = Int64(1) OR b > Int64(3)) AND (b > Int64(2) OR test.c = Int64(1)) AND (b > Int64(2) OR b > Int64(3))\
         \n  Aggregate: groupBy=[[test.a]], aggr=[[SUM(test.b) AS b]]\
-        \n    Filter: test.c = Int64(1) OR test.c = Int64(1)\
-        \n      TableScan: test";

Review Comment:
   Yes, it was my fault.
   `col_c` should not exist in filter.  Need delete it 😂
   Is this case show you fix:  filter with agg result should not push down? @jackwener 



-- 
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] jackwener commented on a diff in pull request #4447: fix `push_down_filter` push `Expr` instead of `column`.

Posted by GitBox <gi...@apache.org>.
jackwener commented on code in PR #4447:
URL: https://github.com/apache/arrow-datafusion/pull/4447#discussion_r1036664955


##########
datafusion/optimizer/src/push_down_filter.rs:
##########
@@ -643,18 +643,25 @@ impl OptimizerRule for PushDownFilter {
                 for expr in predicates {
                     let columns = expr.to_columns()?;
                     if columns.is_empty()
-                        || !columns
-                            .intersection(&used_columns)
-                            .collect::<HashSet<_>>()
-                            .is_empty()

Review Comment:
   Yes. For push_down_filter through Agg, we can push `Expr` in `groupby_expr`.
   Has add it.



-- 
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] Ted-Jiang commented on a diff in pull request #4447: fix `push_down_filter` push `Expr` instead of `column`.

Posted by GitBox <gi...@apache.org>.
Ted-Jiang commented on code in PR #4447:
URL: https://github.com/apache/arrow-datafusion/pull/4447#discussion_r1036727421


##########
datafusion/optimizer/src/push_down_filter.rs:
##########
@@ -910,11 +922,9 @@ mod tests {
         // rewrite to CNF
         // (c = 1 OR c = 1) [can pushDown] AND (c = 1 OR b > 3) AND (b > 2 OR C = 1) AND (b > 2 OR b > 3)
 
-        let expected = "\
-        Filter: (test.c = Int64(1) OR b > Int64(3)) AND (b > Int64(2) OR test.c = Int64(1)) AND (b > Int64(2) OR b > Int64(3))\
+        let expected = "Filter: (test.c = Int64(1) OR test.c = Int64(1)) AND (test.c = Int64(1) OR b > Int64(3)) AND (b > Int64(2) OR test.c = Int64(1)) AND (b > Int64(2) OR b > Int64(3))\
         \n  Aggregate: groupBy=[[test.a]], aggr=[[SUM(test.b) AS b]]\
-        \n    Filter: test.c = Int64(1) OR test.c = Int64(1)\
-        \n      TableScan: test";

Review Comment:
   Yes, it was my fault.
   `col_c` should not exist in filter.  Need delete it 😂
    @jackwener 



-- 
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 merged pull request #4447: fix `push_down_filter` for pushing filters on grouping columns rather than aggregate columns

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


-- 
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