-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add test for Simplify redundant predicates #3915
Conversation
Write rules to simplify both `a OR a` and `a AND a` to a.
Thank you for the PR @src255, I think it looks pretty good as is (an example comparison is available inside |
Thanks for the feedback. Here is the new test I wrote with #[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)))) // use `or` instead of `and`
.unwrap()
.build()
.unwrap();
assert_optimized_plan_eq(
&plan,
"\
Filter: test.b > Int32(1)\
\n Projection: test.a\
\n TableScan: test",
);
} After running this test, I noticed that both
Also, I looked at the feedback from clippy and removed the needless references of |
Thanks for checking it out. That seems to be true (the simplification below) 🤔 (which probably means somewhere in the #3859 we are missing something else, cc: @alamb @Ted-Jiang). |
Test simplification of `a OR a` --> `a` and remove unnecessary rules introduced in the previous commit.
Thanks for the test and investigation @src255 and @isidentical -- clearly I got something wrong. |
* 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.
Write rules to simplify both
a OR a
anda AND a
toa
.Hello! I wanted to help with issue #3895. This is my attempt, but I'm not sure if this is the desired comparison of the
left
andright
fields of theBinaryExpr
struct. I hope this helps and I would appreciate any feedback!Which issue does this PR close?
Closes #3895 .