cloud-fan commented on code in PR #47877:
URL: https://github.com/apache/spark/pull/47877#discussion_r1740486656


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/expressions.scala:
##########
@@ -598,7 +598,9 @@ object SimplifyConditionals extends Rule[LogicalPlan] {
         // a branch with a true condition eliminates all following branches,
         // these branches can be pruned away
         val (h, t) = branches.span(_._1 != TrueLiteral)
-        CaseWhen( h :+ t.head, None)
+        // Use the value of TrueLiteral expression as elseValue to maintain
+        // nullability of CaseWhen expressions
+        CaseWhen(h :+ t.head, t.head._2)

Review Comment:
   shall we update `CaseWhen#nullable` to consider conditions that are true 
literal? My point is we should keep the expression tree small for the good of 
optimizer, and the else value will never be used here.



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

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