Github user dbtsai commented on a diff in the pull request:
https://github.com/apache/spark/pull/21852#discussion_r205599224
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/expressions.scala
---
@@ -416,6 +416,29 @@ 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 e @ CaseWhen(branches, Some(elseValue)) if {
+ val list = branches.map(_._2) :+ elseValue
+ list.tail.forall(list.head.semanticEquals)
+ } =>
+ // For non-deterministic conditions with side effect, we can not
remove it, or change
+ // the ordering. As a result, we try to remove the deterministic
conditions from the tail.
+ val newBranches = branches.map(_._1)
--- End diff --
@viirya I think this can address your concern. Thanks.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]