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/07/22 16:04:05 UTC
[GitHub] [arrow-datafusion] AssHero opened a new pull request, #2958: Negate clause
AssHero opened a new pull request, #2958:
URL: https://github.com/apache/arrow-datafusion/pull/2958
# Which issue does this PR close?
Closes #2957
# Rationale for this change
negate a Not clause
For BinaryExpr, use the negator of op instead.
not ( A > B) ===> (A <= B)
For BoolExpr, not (A and B) ===> (not A) or (not B)
not (A or B) ===> (not A) and (not B)
not (not A) ===> A
For NullExpr, not (A is not null) ===> A is null
not (A is null) ===> A is not null
For InList, not (A not in (..)) ===> A in (..)
not (A in (..)) ===> A not in (..)
For Between, not (A between B and C) ===> (A not between B and C)
not (A not between B and C) ===> (A between B and C)
For others, use Not clause
# What changes are included in this PR?
Add rules to simplify not clause in datafusion/optimizer/src/simplify_expressions.rs
--
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 #2958: Simplify expressions with `NOT` clause
Posted by GitBox <gi...@apache.org>.
alamb merged PR #2958:
URL: https://github.com/apache/arrow-datafusion/pull/2958
--
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] AssHero commented on a diff in pull request #2958: Simplify expressions with `NOT` clause
Posted by GitBox <gi...@apache.org>.
AssHero commented on code in PR #2958:
URL: https://github.com/apache/arrow-datafusion/pull/2958#discussion_r928268943
##########
datafusion/optimizer/src/simplify_expressions.rs:
##########
@@ -185,6 +181,97 @@ fn as_bool_lit(expr: Expr) -> Option<bool> {
}
}
+/// negate a Not clause
+/// input is the clause to be negated.(args of Not clause)
+/// For BinaryExpr, use the negator of op instead.
+/// not ( A > B) ===> (A <= B)
+/// For BoolExpr, not (A and B) ===> (not A) or (not B)
+/// not (A or B) ===> (not A) and (not B)
+/// not (not A) ===> A
+/// For NullExpr, not (A is not null) ===> A is null
+/// not (A is null) ===> A is not null
+/// For InList, not (A not in (..)) ===> A in (..)
+/// not (A in (..)) ===> A not in (..)
+/// For Between, not (A between B and C) ===> (A not between B and C)
+/// not (A not between B and C) ===> (A between B and C)
+/// For others, use Not clause
+fn negate_clause(expr: Expr) -> Expr {
+ match expr {
+ Expr::BinaryExpr { left, op, right } => {
+ match op {
+ // not (A = B) ===> (A <> B)
+ Operator::Eq => binary_expr(*left, Operator::NotEq, *right),
Review Comment:
I think it's better than new allocation. Let me fix this. Thanks!
--
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] AssHero commented on pull request #2958: Simplify expressions with `NOT` clause
Posted by GitBox <gi...@apache.org>.
AssHero commented on PR #2958:
URL: https://github.com/apache/arrow-datafusion/pull/2958#issuecomment-1193339353
Refine the code according to the comments.
--
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] codecov-commenter commented on pull request #2958: Simplify expressions with `NOT` clause
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #2958:
URL: https://github.com/apache/arrow-datafusion/pull/2958#issuecomment-1193347032
# [Codecov](https://codecov.io/gh/apache/arrow-datafusion/pull/2958?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#2958](https://codecov.io/gh/apache/arrow-datafusion/pull/2958?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (4f2c41e) into [master](https://codecov.io/gh/apache/arrow-datafusion/commit/117df4d4fa2881435a428cff3ab5880c3b8632e1?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (117df4d) will **increase** coverage by `0.23%`.
> The diff coverage is `94.14%`.
> :exclamation: Current head 4f2c41e differs from pull request most recent head 9d57e89. Consider uploading reports for the commit 9d57e89 to get more accurate results
```diff
@@ Coverage Diff @@
## master #2958 +/- ##
==========================================
+ Coverage 85.42% 85.65% +0.23%
==========================================
Files 275 279 +4
Lines 49839 51076 +1237
==========================================
+ Hits 42575 43751 +1176
- Misses 7264 7325 +61
```
| [Impacted Files](https://codecov.io/gh/apache/arrow-datafusion/pull/2958?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...tafusion/core/src/physical\_plan/file\_format/mod.rs](https://codecov.io/gh/apache/arrow-datafusion/pull/2958/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZGF0YWZ1c2lvbi9jb3JlL3NyYy9waHlzaWNhbF9wbGFuL2ZpbGVfZm9ybWF0L21vZC5ycw==) | `97.36% <ø> (ø)` | |
| [datafusion/core/tests/sql/joins.rs](https://codecov.io/gh/apache/arrow-datafusion/pull/2958/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZGF0YWZ1c2lvbi9jb3JlL3Rlc3RzL3NxbC9qb2lucy5ycw==) | `99.31% <ø> (ø)` | |
| [datafusion/optimizer/src/test/mod.rs](https://codecov.io/gh/apache/arrow-datafusion/pull/2958/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZGF0YWZ1c2lvbi9vcHRpbWl6ZXIvc3JjL3Rlc3QvbW9kLnJz) | `94.23% <92.10%> (-5.77%)` | :arrow_down: |
| [...usion/optimizer/src/decorrelate\_scalar\_subquery.rs](https://codecov.io/gh/apache/arrow-datafusion/pull/2958/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZGF0YWZ1c2lvbi9vcHRpbWl6ZXIvc3JjL2RlY29ycmVsYXRlX3NjYWxhcl9zdWJxdWVyeS5ycw==) | `92.72% <92.72%> (ø)` | |
| [...tafusion/optimizer/src/decorrelate\_where\_exists.rs](https://codecov.io/gh/apache/arrow-datafusion/pull/2958/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZGF0YWZ1c2lvbi9vcHRpbWl6ZXIvc3JjL2RlY29ycmVsYXRlX3doZXJlX2V4aXN0cy5ycw==) | `93.42% <93.42%> (ø)` | |
| [datafusion/expr/src/logical\_plan/plan.rs](https://codecov.io/gh/apache/arrow-datafusion/pull/2958/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZGF0YWZ1c2lvbi9leHByL3NyYy9sb2dpY2FsX3BsYW4vcGxhbi5ycw==) | `77.43% <93.75%> (+0.46%)` | :arrow_up: |
| [datafusion/optimizer/src/utils.rs](https://codecov.io/gh/apache/arrow-datafusion/pull/2958/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZGF0YWZ1c2lvbi9vcHRpbWl6ZXIvc3JjL3V0aWxzLnJz) | `92.17% <93.75%> (+3.60%)` | :arrow_up: |
| [datafusion/core/tests/sql/mod.rs](https://codecov.io/gh/apache/arrow-datafusion/pull/2958/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZGF0YWZ1c2lvbi9jb3JlL3Rlc3RzL3NxbC9tb2QucnM=) | `98.26% <94.02%> (-0.56%)` | :arrow_down: |
| [datafusion/optimizer/src/decorrelate\_where\_in.rs](https://codecov.io/gh/apache/arrow-datafusion/pull/2958/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZGF0YWZ1c2lvbi9vcHRpbWl6ZXIvc3JjL2RlY29ycmVsYXRlX3doZXJlX2luLnJz) | `94.11% <94.11%> (ø)` | |
| [datafusion/core/tests/sql/subqueries.rs](https://codecov.io/gh/apache/arrow-datafusion/pull/2958/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZGF0YWZ1c2lvbi9jb3JlL3Rlc3RzL3NxbC9zdWJxdWVyaWVzLnJz) | `94.32% <94.32%> (ø)` | |
| ... and [13 more](https://codecov.io/gh/apache/arrow-datafusion/pull/2958/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
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 #2958: Simplify expressions with `NOT` clause
Posted by GitBox <gi...@apache.org>.
ursabot commented on PR #2958:
URL: https://github.com/apache/arrow-datafusion/pull/2958#issuecomment-1194008345
Benchmark runs are scheduled for baseline = 7b0f2f846a7c8c2ffee2a4f29772cf3527a8d92c and contender = f386f7a7344d54455fe04d92248e373fac990e6d. f386f7a7344d54455fe04d92248e373fac990e6d 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/7c10675c0e744e43a18915b2cce6cc8e...49fbdc99b60448c3a59100564081dc29/)
[Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on test-mac-arm] [test-mac-arm](https://conbench.ursa.dev/compare/runs/84333771ab8b4d07bbb89bb651c5536e...78fbdf9f587d4ca18aab88d7eff0ad4f/)
[Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ursa-i9-9960x] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/ce3a0ea137ec4d7b8f058220cc21cfe2...40fbdd82975e40178ea849f4e020792b/)
[Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ursa-thinkcentre-m75q] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/ee57a917618644848e3c905d0bf311fd...874097eb45214bfd94e7b923827686ea/)
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] alamb commented on pull request #2958: Simplify expressions with `NOT` clause
Posted by GitBox <gi...@apache.org>.
alamb commented on PR #2958:
URL: https://github.com/apache/arrow-datafusion/pull/2958#issuecomment-1193998543
Thanks @AssHero and @liukun4515 !
--
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] AssHero commented on a diff in pull request #2958: Simplify expressions with `NOT` clause
Posted by GitBox <gi...@apache.org>.
AssHero commented on code in PR #2958:
URL: https://github.com/apache/arrow-datafusion/pull/2958#discussion_r928187591
##########
datafusion/optimizer/src/simplify_expressions.rs:
##########
@@ -1434,7 +1516,7 @@ mod tests {
],
else_expr: Some(Box::new(lit(true))),
})),
- col("c1").or(col("c1").or(col("c2")).not())
+ col("c1").or(col("c1").not().and(col("c2").not()))
Review Comment:
Yes, I'll update the comments! Thanks!
--
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 #2958: Negate not clause
Posted by GitBox <gi...@apache.org>.
alamb commented on code in PR #2958:
URL: https://github.com/apache/arrow-datafusion/pull/2958#discussion_r928169456
##########
datafusion/core/tests/sql/joins.rs:
##########
@@ -1567,7 +1567,7 @@ async fn reduce_right_join_2() -> Result<()> {
let expected = vec![
"Explain [plan_type:Utf8, plan:Utf8]",
" Projection: #t1.t1_id, #t1.t1_name, #t1.t1_int, #t2.t2_id, #t2.t2_name, #t2.t2_int [t1_id:UInt32;N, t1_name:Utf8;N, t1_int:UInt32;N, t2_id:UInt32;N, t2_name:Utf8;N, t2_int:UInt32;N]",
- " Filter: NOT #t1.t1_int = #t2.t2_int [t1_id:UInt32;N, t1_name:Utf8;N, t1_int:UInt32;N, t2_id:UInt32;N, t2_name:Utf8;N, t2_int:UInt32;N]",
+ " Filter: #t1.t1_int != #t2.t2_int [t1_id:UInt32;N, t1_name:Utf8;N, t1_int:UInt32;N, t2_id:UInt32;N, t2_name:Utf8;N, t2_int:UInt32;N]",
Review Comment:
👍
##########
datafusion/optimizer/src/simplify_expressions.rs:
##########
@@ -185,6 +181,97 @@ fn as_bool_lit(expr: Expr) -> Option<bool> {
}
}
+/// negate a Not clause
+/// input is the clause to be negated.(args of Not clause)
+/// For BinaryExpr, use the negator of op instead.
+/// not ( A > B) ===> (A <= B)
+/// For BoolExpr, not (A and B) ===> (not A) or (not B)
+/// not (A or B) ===> (not A) and (not B)
+/// not (not A) ===> A
+/// For NullExpr, not (A is not null) ===> A is null
+/// not (A is null) ===> A is not null
+/// For InList, not (A not in (..)) ===> A in (..)
+/// not (A in (..)) ===> A not in (..)
+/// For Between, not (A between B and C) ===> (A not between B and C)
+/// not (A not between B and C) ===> (A between B and C)
+/// For others, use Not clause
+fn negate_clause(expr: Expr) -> Expr {
+ match expr {
+ Expr::BinaryExpr { left, op, right } => {
+ match op {
+ // not (A = B) ===> (A <> B)
+ Operator::Eq => binary_expr(*left, Operator::NotEq, *right),
+ // not (A <> B) ===> (A = B)
+ Operator::NotEq => binary_expr(*left, Operator::Eq, *right),
+ // not (A < B) ===> (A >= B)
+ Operator::Lt => binary_expr(*left, Operator::GtEq, *right),
+ // not (A <= B) ===> (A > B)
+ Operator::LtEq => binary_expr(*left, Operator::Gt, *right),
+ // not (A > B) ===> (A <= B)
+ Operator::Gt => binary_expr(*left, Operator::LtEq, *right),
+ // not (A >= B) ===> (A < B)
+ Operator::GtEq => binary_expr(*left, Operator::Lt, *right),
+ // not (A like 'B') ===> (A not like 'B')
+ Operator::Like => binary_expr(*left, Operator::NotLike, *right),
+ // not (A not like 'B') ===> (A like 'B')
+ Operator::NotLike => binary_expr(*left, Operator::Like, *right),
+ // not (A is distinct from B) ===> (A is not distinct from B)
+ Operator::IsDistinctFrom => {
+ binary_expr(*left, Operator::IsNotDistinctFrom, *right)
+ }
+ // not (A is not distinct from B) ===> (A is distinct from B)
+ Operator::IsNotDistinctFrom => {
+ binary_expr(*left, Operator::IsDistinctFrom, *right)
+ }
+ // not (A and B) ===> (not A) or (not B)
+ Operator::And => {
+ let left = negate_clause(*left);
+ let right = negate_clause(*right);
+
+ or(left, right)
+ }
+ // not (A or B) ===> (not A) and (not B)
+ Operator::Or => {
+ let left = negate_clause(*left);
+ let right = negate_clause(*right);
+
+ and(left, right)
+ }
+ // use not clause
+ _ => Expr::Not(Box::new(binary_expr(*left, op, *right))),
+ }
+ }
+ // not (not A) ===> A
+ Expr::Not(expr) => *expr,
+ // not (A is not null) ===> A is null
+ Expr::IsNotNull(expr) => expr.is_null(),
+ // not (A is null) ===> A is not null
+ Expr::IsNull(expr) => expr.is_not_null(),
+ // not (A not in (..)) ===> A in (..)
+ // not (A in (..)) ===> A not in (..)
+ Expr::InList {
+ expr,
+ list,
+ negated,
+ } => expr.in_list(list, !negated),
+ // not (A between B and C) ===> (A not between B and C)
+ // not (A not between B and C) ===> (A between B and C)
+ Expr::Between {
+ expr,
+ negated,
+ low,
+ high,
+ } => Expr::Between {
+ expr,
+ negated: !negated,
+ low,
+ high,
+ },
+ // use not clause
Review Comment:
👍 I reviewed this logic carefully
##########
datafusion/optimizer/src/simplify_expressions.rs:
##########
@@ -185,6 +181,97 @@ fn as_bool_lit(expr: Expr) -> Option<bool> {
}
}
+/// negate a Not clause
+/// input is the clause to be negated.(args of Not clause)
+/// For BinaryExpr, use the negator of op instead.
+/// not ( A > B) ===> (A <= B)
+/// For BoolExpr, not (A and B) ===> (not A) or (not B)
+/// not (A or B) ===> (not A) and (not B)
+/// not (not A) ===> A
+/// For NullExpr, not (A is not null) ===> A is null
+/// not (A is null) ===> A is not null
+/// For InList, not (A not in (..)) ===> A in (..)
+/// not (A in (..)) ===> A not in (..)
+/// For Between, not (A between B and C) ===> (A not between B and C)
+/// not (A not between B and C) ===> (A between B and C)
+/// For others, use Not clause
+fn negate_clause(expr: Expr) -> Expr {
+ match expr {
+ Expr::BinaryExpr { left, op, right } => {
+ match op {
+ // not (A = B) ===> (A <> B)
+ Operator::Eq => binary_expr(*left, Operator::NotEq, *right),
Review Comment:
I don't know if it matters, but `binary_expr` may cause a new allocation via `Box` -- I wonder if this code could be written to just pick a new op and reassmble the expr, like
```rust
Expr::BinaryExpr { left, op, right } => Expr::BinaryExpr { left, op: negate_op(op), right }
```
not necessary, just something that I thought of
##########
datafusion/optimizer/src/simplify_expressions.rs:
##########
@@ -905,7 +987,7 @@ mod tests {
Operator::And,
Expr::not(col("c2").gt(lit(5))),
);
- let expected = expr.clone();
+ let expected = col("c2").gt(lit(5)).and(col("c2").lt_eq(lit(5)));
Review Comment:
Maybe can we update the comment above as well
from
```rust
// (c > 5) AND !(c > 5) -- can't remove
```
to
```rust
// (c > 5) AND !(c > 5) -- > (c > 5) AND (c <= 5)
```
##########
datafusion/optimizer/src/simplify_expressions.rs:
##########
@@ -185,6 +181,97 @@ fn as_bool_lit(expr: Expr) -> Option<bool> {
}
}
+/// negate a Not clause
+/// input is the clause to be negated.(args of Not clause)
+/// For BinaryExpr, use the negator of op instead.
+/// not ( A > B) ===> (A <= B)
+/// For BoolExpr, not (A and B) ===> (not A) or (not B)
+/// not (A or B) ===> (not A) and (not B)
+/// not (not A) ===> A
+/// For NullExpr, not (A is not null) ===> A is null
+/// not (A is null) ===> A is not null
+/// For InList, not (A not in (..)) ===> A in (..)
+/// not (A in (..)) ===> A not in (..)
+/// For Between, not (A between B and C) ===> (A not between B and C)
+/// not (A not between B and C) ===> (A between B and C)
+/// For others, use Not clause
+fn negate_clause(expr: Expr) -> Expr {
+ match expr {
+ Expr::BinaryExpr { left, op, right } => {
+ match op {
+ // not (A = B) ===> (A <> B)
+ Operator::Eq => binary_expr(*left, Operator::NotEq, *right),
+ // not (A <> B) ===> (A = B)
+ Operator::NotEq => binary_expr(*left, Operator::Eq, *right),
+ // not (A < B) ===> (A >= B)
+ Operator::Lt => binary_expr(*left, Operator::GtEq, *right),
+ // not (A <= B) ===> (A > B)
+ Operator::LtEq => binary_expr(*left, Operator::Gt, *right),
+ // not (A > B) ===> (A <= B)
+ Operator::Gt => binary_expr(*left, Operator::LtEq, *right),
+ // not (A >= B) ===> (A < B)
+ Operator::GtEq => binary_expr(*left, Operator::Lt, *right),
+ // not (A like 'B') ===> (A not like 'B')
+ Operator::Like => binary_expr(*left, Operator::NotLike, *right),
+ // not (A not like 'B') ===> (A like 'B')
+ Operator::NotLike => binary_expr(*left, Operator::Like, *right),
+ // not (A is distinct from B) ===> (A is not distinct from B)
+ Operator::IsDistinctFrom => {
+ binary_expr(*left, Operator::IsNotDistinctFrom, *right)
+ }
+ // not (A is not distinct from B) ===> (A is distinct from B)
+ Operator::IsNotDistinctFrom => {
+ binary_expr(*left, Operator::IsDistinctFrom, *right)
+ }
+ // not (A and B) ===> (not A) or (not B)
+ Operator::And => {
+ let left = negate_clause(*left);
+ let right = negate_clause(*right);
+
+ or(left, right)
+ }
+ // not (A or B) ===> (not A) and (not B)
Review Comment:
nice
##########
datafusion/optimizer/src/simplify_expressions.rs:
##########
@@ -1453,7 +1535,7 @@ mod tests {
],
else_expr: Some(Box::new(lit(true))),
})),
- col("c1").or(col("c1").or(col("c2")).not())
+ col("c1").or(col("c1").not().and(col("c2").not()))
Review Comment:
And one more place to update the comments?
##########
datafusion/optimizer/src/simplify_expressions.rs:
##########
@@ -1434,7 +1516,7 @@ mod tests {
],
else_expr: Some(Box::new(lit(true))),
})),
- col("c1").or(col("c1").or(col("c2")).not())
+ col("c1").or(col("c1").not().and(col("c2").not()))
Review Comment:
Can you please update the comments here as well?
--
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