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/23 18:42:50 UTC

[GitHub] [spark] sunchao commented on a change in pull request #34055: [SPARK-36721][SQL] Simplify boolean equalities if one side is literal

sunchao commented on a change in pull request #34055:
URL: https://github.com/apache/spark/pull/34055#discussion_r715060070



##########
File path: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/BinaryComparisonSimplificationSuite.scala
##########
@@ -194,4 +199,15 @@ class BinaryComparisonSimplificationSuite extends PlanTest with PredicateHelper
       Optimize.execute(testRelation.select(Coalesce(Seq('b, 'd)).as("out")).analyze),
       testRelation.select(Coalesce(Seq('b, 'd)).as("out")).analyze)
   }
+
+  test("SPARK-36721: Simplify boolean equalities if one side is literal") {
+    checkCondition(boolRelation, And('a, 'b) === TrueLiteral, And('a, 'b))
+    checkCondition(boolRelation, TrueLiteral === And('a, 'b), And('a, 'b))
+    checkCondition(boolRelation, And('a, 'b) === FalseLiteral, Or(Not('a), Not('b)))
+    checkCondition(boolRelation, FalseLiteral === And('a, 'b), Or(Not('a), Not('b)))
+    checkCondition(boolRelation, IsNull('a) <=> TrueLiteral, IsNull('a))

Review comment:
       maybe ideally test the case when LHS is nullable but this is just a nit




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