You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by al...@apache.org on 2022/10/22 10:46:05 UTC
[arrow-datafusion] branch master updated: Simplify redundant predicates (#3915)
This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git
The following commit(s) were added to refs/heads/master by this push:
new 83b54f630 Simplify redundant predicates (#3915)
83b54f630 is described below
commit 83b54f630a43f4af64b87965ed5b739b28d3a900
Author: Christian Salvati <81...@users.noreply.github.com>
AuthorDate: Sat Oct 22 06:46:01 2022 -0400
Simplify redundant predicates (#3915)
* Simplify redundant predicates
Write rules to simplify both `a OR a` and `a AND a` to a.
* Add test for redudant `or` expression
Test simplification of `a OR a` --> `a` and remove unnecessary rules
introduced in the previous commit.
---
datafusion/optimizer/src/simplify_expressions.rs | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/datafusion/optimizer/src/simplify_expressions.rs b/datafusion/optimizer/src/simplify_expressions.rs
index 03f79feba..bc3ac6e84 100644
--- a/datafusion/optimizer/src/simplify_expressions.rs
+++ b/datafusion/optimizer/src/simplify_expressions.rs
@@ -2152,6 +2152,26 @@ mod tests {
);
}
+ #[test]
+ fn test_simplify_optimized_plan_with_or() {
+ let table_scan = test_table_scan();
+ let plan = LogicalPlanBuilder::from(table_scan)
+ .project(vec![col("a")])
+ .unwrap()
+ .filter(or(col("b").gt(lit(1)), col("b").gt(lit(1))))
+ .unwrap()
+ .build()
+ .unwrap();
+
+ assert_optimized_plan_eq(
+ &plan,
+ "\
+ Filter: test.b > Int32(1)\
+ \n Projection: test.a\
+ \n TableScan: test",
+ );
+ }
+
#[test]
fn test_simplify_optimized_plan_with_composed_and() {
let table_scan = test_table_scan();