cloud-fan commented on a change in pull request #30222: URL: https://github.com/apache/spark/pull/30222#discussion_r517787607
########## File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/expressions.scala ########## @@ -510,6 +510,14 @@ object SimplifyConditionals extends Rule[LogicalPlan] with PredicateHelper { } else { e.copy(branches = branches.take(i).map(branch => (branch._1, elseValue))) } + + case EqualTo(CaseWhen(branches, elseValue), right) + if right.foldable && branches.forall(_._2.foldable) => + (branches.filter(_._2.equals(right)).map(_._1) ++ Review comment: `equals` is only well implemented in `Literal`, but the condition we use is `.foldable`. Shall we change the condition to `.isInstanceOf[Literal]` and wait for the constant folding rule before running this rule? ---------------------------------------------------------------- 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: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org