tanelk commented on a change in pull request #30849:
URL: https://github.com/apache/spark/pull/30849#discussion_r546242889



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/expressions.scala
##########
@@ -475,6 +475,8 @@ object SimplifyConditionals extends Rule[LogicalPlan] with 
PredicateHelper {
       case If(TrueLiteral, trueValue, _) => trueValue
       case If(FalseLiteral, _, falseValue) => falseValue
       case If(Literal(null, _), _, falseValue) => falseValue
+      case If(cond, TrueLiteral, FalseLiteral) if cond.deterministic => cond

Review comment:
       It is a slightly different situation.
   In the one you linked, the condition will not be evaluated after the 
optimization.
   Here the condition will be evaluated the same amount of times with and 
without the optimizer - meaning this optimization is okay for even 
non-deterministic expressions.




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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to