peter-toth commented on code in PR #46135:
URL: https://github.com/apache/spark/pull/46135#discussion_r1572557495
##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/SubexpressionEliminationSuite.scala:
##########
@@ -494,6 +494,18 @@ class SubexpressionEliminationSuite extends SparkFunSuite
with ExpressionEvalHel
checkShortcut(Or(equal, Literal(true)), 1)
checkShortcut(Not(And(equal, Literal(false))), 1)
}
+
+ test("Equivalent ternary expressions have different children") {
Review Comment:
Hmm, this is because `((1 + 2) + 3)` semanticEquals to `((3 + 1) + 2)` but
their children are different. So when we compute the common elements between
the above 2 here:
https://github.com/apache/spark/blob/0d553d06fe2f05571531ada0f08c0cc45418e941/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/EquivalentExpressions.scala#L112-L121
only `((1 + 2) + 3)` remains in `localEquivalenceMap` but it's children
don't. So later when we want to remove `((1 + 2) + 3)` we can't find its
children...
I think we could fix the above code that computes `localEquivalenceMap`, but
the change in PR is simpler and doesn't seem to do any harm.
--
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]