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



##########
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") {
+    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),

Review comment:
       @maropu Many thanks for reviews. Is there a plugin or formatting config 
that spark community uses to correct these formatting issues in IDE itself ?




----------------------------------------------------------------
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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to