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 2020/12/14 08:36:53 UTC

[GitHub] [spark] cloud-fan commented on a change in pull request #30222: [SPARK-33315][SQL] Simplify CaseWhen with EqualTo

cloud-fan commented on a change in pull request #30222:
URL: https://github.com/apache/spark/pull/30222#discussion_r542199756



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/expressions.scala
##########
@@ -523,6 +523,16 @@ object SimplifyConditionals extends Rule[LogicalPlan] with PredicateHelper {
         } else {
           e.copy(branches = branches.take(i).map(branch => (branch._1, elseValue)))
         }
+
+      case e @ EqualTo(c @ CaseWhen(branches, elseValue), right)
+          if c.deterministic &&
+            right.isInstanceOf[Literal] && branches.forall(_._2.isInstanceOf[Literal]) &&
+            elseValue.forall(_.isInstanceOf[Literal]) =>
+        if ((branches.map(_._2) ++ elseValue).forall(!_.equals(right))) {

Review comment:
       can we use an `EqualTo` expression to compare literals? and how about the null semantic?




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