Kimahriman commented on a change in pull request #33142:
URL: https://github.com/apache/spark/pull/33142#discussion_r661627361
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/EquivalentExpressions.scala
##########
@@ -135,33 +125,47 @@ class EquivalentExpressions {
// For some special expressions we cannot just recurse into all of its
children, but we can
// recursively add the common expressions shared between all of its children.
private def commonChildrenToRecurse(expr: Expression): Seq[Seq[Expression]]
= expr match {
+ case _: CodegenFallback => Nil
case i: If => Seq(Seq(i.trueValue, i.falseValue))
case c: CaseWhen =>
// We look at subexpressions in conditions and values of `CaseWhen`
separately. It is
// because a subexpression in conditions will be run no matter which
condition is matched
// if it is shared among conditions, but it doesn't need to be shared in
values. Similarly,
// a subexpression among values doesn't need to be in conditions because
no matter which
// condition is true, it will be evaluated.
- val conditions = c.branches.tail.map(_._1)
+ val conditions = if (c.branches.length > 1) {
Review comment:
I think he means in `CaseWhen(a + b > 1, 1, a + b + c > 1, 2)`, `a + b`
will be a subexpression even though it might only be executed once.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]