Github user dbtsai commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21850#discussion_r205556780
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/expressions.scala
 ---
    @@ -414,6 +414,9 @@ object SimplifyConditionals extends Rule[LogicalPlan] 
with PredicateHelper {
             // these branches can be pruned away
             val (h, t) = branches.span(_._1 != TrueLiteral)
             CaseWhen( h :+ t.head, None)
    +
    +      case CaseWhen(Seq((cond, trueValue)), elseValue) =>
    +        If(cond, trueValue, elseValue.getOrElse(Literal(null, 
trueValue.dataType)))
    --- End diff --
    
    The generated Java code is slightly simpler, but I agree there should not 
have any performance gain. Being said that, once `CaseWhen` is converted into 
`If`, this condition expression will be benefited from the optimization rules 
in `If` which may not be implemented for `CaseWhen` case.
    



---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to