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/03/02 05:25:39 UTC

[GitHub] [spark] gengliangwang commented on a change in pull request #31318: [SPARK-34222][SQL] Enhance boolean simplification rule

gengliangwang commented on a change in pull request #31318:
URL: https://github.com/apache/spark/pull/31318#discussion_r585268436



##########
File path: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/BooleanSimplificationSuite.scala
##########
@@ -126,6 +126,54 @@ class BooleanSimplificationSuite extends PlanTest with ExpressionEvalHelper with
       'a === 'b || 'b > 3 && 'a > 3 && 'a < 5)
   }
 
+  test("SPARK-34222: (a && b) && a && (a && c) => a && b && c") {

Review comment:
       nit: `SPARK-34222: simplify conjunctive predicates` 

##########
File path: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/BooleanSimplificationSuite.scala
##########
@@ -126,6 +126,54 @@ class BooleanSimplificationSuite extends PlanTest with ExpressionEvalHelper with
       'a === 'b || 'b > 3 && 'a > 3 && 'a < 5)
   }
 
+  test("SPARK-34222: (a && b) && a && (a && c) => a && b && c") {
+    checkCondition(('a > 1 && 'b > 2) && 'a > 1 && ('a > 1 && 'c > 3),
+      'a > 1 && ('b > 2 && 'c > 3))
+
+    checkCondition(('a > 1 && 'b > 2) && ('a > 4 && 'b > 5) && ('a > 1 && 'c > 3),
+      ('a > 1 && 'b > 2) && ('c > 3 && 'a > 4) && 'b > 5)
+
+    checkCondition(
+      'a > 1 && 'b > 3 && ('a > 1 && 'b > 3 && ('a > 1 && 'b > 3 && 'c > 1)),
+      'a > 1 && 'b > 3 && 'c > 1)
+
+    checkCondition(
+      ('a > 1 || 'b > 3) && (('a > 1 || 'b > 3) && 'd > 0 && (('a > 1 || 'b > 3) && 'c > 1)),
+      ('a > 1 || 'b > 3) && 'd > 0 && 'c > 1)
+
+    checkCondition(
+      'a > 1 && 'b > 2 && 'a > 1 && 'c > 3,
+      'a > 1 && 'b > 2 && 'c > 3)
+
+    checkCondition(
+      ('a > 1 && 'b > 3 && 'a > 1) || ('a > 1 && 'b > 3 && 'a > 1 && 'c > 1),
+      'a > 1 && 'b > 3)
+  }
+
+  test("SPARK-34222: (a || b) || a || (a || c) => a || b || c") {

Review comment:
       nit: `SPARK-34222: simplify disjunctive predicates` 




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

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