wangyum commented on a change in pull request #30790:
URL: https://github.com/apache/spark/pull/30790#discussion_r544161542



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/expressions.scala
##########
@@ -523,6 +529,17 @@ object SimplifyConditionals extends Rule[LogicalPlan] with 
PredicateHelper {
         } else {
           e.copy(branches = branches.take(i).map(branch => (branch._1, 
elseValue)))
         }
+
+      // Null value should be handled by NullPropagation.

Review comment:
       How about:
   ```scala
   exps.forall {
     case l: Literal =>
       val res = EqualTo(l, equalTo).eval(EmptyRow)
       res != null && !res.asInstanceOf[Boolean]
     case _ => false
   }
   ```
   
   otherwise this test will fail:
   ```scala
   val nonFoldable = CaseWhen(Seq(normalBranch, (a, b)), None)
   assertEquivalent(EqualTo(nonFoldable, Literal(1)), EqualTo(nonFoldable, 
Literal(1)))
   ```




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