Github user hvanhovell commented on a diff in the pull request:
https://github.com/apache/spark/pull/16043#discussion_r98613413
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/expressions.scala
---
@@ -293,6 +293,12 @@ object SimplifyConditionals extends Rule[LogicalPlan]
with PredicateHelper {
// from that. Note that CaseWhen.branches should never be empty,
and as a result the
// headOption (rather than head) added above is just an extra (and
unnecessary) safeguard.
branches.head._2
+
+ case e @ CaseWhen(branches, _) if branches.exists(_._1 ==
Literal(true)) =>
+ // a branc with a TRue condition eliminates all following branches,
+ // these branches can be pruned away
+ val (h, t) = branches.span(_._1 != Literal(true))
+ CaseWhen( h :+ t.head, None)
--- End diff --
Nit space
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]