You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/09/08 17:42:15 UTC

[GitHub] [spark] kazuyukitanimura commented on a change in pull request #33930: [SPARK-36665][SQL] Add more Not operator simplifications

kazuyukitanimura commented on a change in pull request #33930:
URL: https://github.com/apache/spark/pull/33930#discussion_r704639466



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/expressions.scala
##########
@@ -441,6 +456,24 @@ object BooleanSimplification extends Rule[LogicalPlan] with PredicateHelper {
 
       case Not(IsNull(e)) => IsNotNull(e)
       case Not(IsNotNull(e)) => IsNull(e)
+
+      // Using Not(null) == null rules
+      case IsNull(Not(e)) => IsNull(e)
+      case IsNotNull(Not(e)) => IsNotNull(e)
+
+      // Using (Not(a) === b) == (a === Not(b)), (Not(a) <=> b) == (a <=> Not(b)) rules
+      case EqualTo(Not(a), b) if canSimplifyNot(b) => EqualTo(a, Not(b))

Review comment:
       For example of the `EqualTo(Not(a), b)` where `b = Not(c)`, it will become `EqualTo(a, Not(b))` => `EqualTo(a, Not(Not(c)))` => `EqualTo(a, c)`
   In addition, `if canSimplifyNot(b)` checks if the optimization can converge that avoids the situation two conditions are returning to each other.
   I plan to add those explanations to the 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: reviews-unsubscribe@spark.apache.org

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



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org