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/14 00:50:43 UTC

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

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



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/expressions.scala
##########
@@ -288,8 +288,24 @@ object OptimizeIn extends Rule[LogicalPlan] {
  * 2. Eliminates / extracts common factors.
  * 3. Merge same expressions
  * 4. Removes `Not` operator.
+ * 5. Move/Push `Not` operator if it's beneficial.
  */
 object BooleanSimplification extends Rule[LogicalPlan] with PredicateHelper {
+  // Given argument x, return true if expression Not(x) can be simplified
+  // E.g. let x == Not(y), then canSimplifyNot(x) == true because Not(x) == Not(Not(y)) == y
+  // For the case of x = EqualTo(a, b), recursively check each child expression
+  // Extra nullable check is required for EqualNullSafe because
+  // Not(EqualNullSafe(x, null)) is different from EqualNullSafe(x, Not(null))
+  private def canSimplifyNot(x: Expression): Boolean = x match {

Review comment:
       Does `canSimplifyNot` returning true for an expression `x` means that `Not(x)` can be optimized later to remove `Not`?




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