Kimahriman commented on a change in pull request #33142:
URL: https://github.com/apache/spark/pull/33142#discussion_r661573328
##########
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:
Yeah this definitely fixes a potential bug of creating subexpressions
for things that are never evaluated, same with the coalesce update. I think the
values are already handled fine, it's just the conditionals that had an issue
with short circuiting
--
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]