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/11/15 07:59:47 UTC

[GitHub] [spark] cloud-fan commented on a change in pull request #34580: [SPARK-37270][SQL] Fix push foldable into CaseWhen branches if elseValue is empty

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



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/expressions.scala
##########
@@ -681,7 +681,9 @@ object PushFoldableIntoBranches extends Rule[LogicalPlan] with PredicateHelper {
           if supportedUnaryExpression(u) && atMostOneUnfoldable(branches.map(_._2) ++ elseValue) =>
         c.copy(
           branches.map(e => e.copy(_2 = u.withNewChildren(Array(e._2)))),
-          elseValue.map(e => u.withNewChildren(Array(e))))
+          elseValue
+            .orElse { if (u.isInstanceOf[IsNull]) Some(Literal(null, c.dataType)) else None }

Review comment:
       Can we optimize away the useless else branch? I think null propagation + removing null else branch should do the work?




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