dongjoon-hyun commented on a change in pull request #29776:
URL: https://github.com/apache/spark/pull/29776#discussion_r489797436
##########
File path:
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodegenExpressionCachingSuite.scala
##########
@@ -85,6 +85,36 @@ class CodegenExpressionCachingSuite extends SparkFunSuite {
assert(instance2.eval(null))
}
+ test("SPARK-32903: GeneratePredicate should eliminate sub-expressions") {
+ Seq(true, false).foreach { enabled =>
+ val leaf1 = ExprWithEvaluatedState()
+ val leaf2 = ExprWithEvaluatedState()
+ val leaf3 = ExprWithEvaluatedState()
+ val leaf4 = ExprWithEvaluatedState()
+
+ val expr1 = And(leaf1, leaf2)
+ val expr2 = And(leaf3, leaf4)
+ val cond = Or(expr1, expr2)
+ val instance = GeneratePredicate.generate(cond, useSubexprElimination =
enabled)
+ instance.initialize(0)
+ assert(instance.eval(null) === false)
+
+ if (enabled) {
+ // When we do sub-expression elimination, Spark thought `expr1` and
`expr2` are
+ // the same, so when it wants to evaluate `expr2`, it gets previous
evaluation of `expr1`.
Review comment:
This looks misleading to me because this `expr1` and `expr2` conflicts
with line 95 and 96. In this context, this `expr1` and `expr2` is general ones
and not referring line 95 and 96, right? If these refer the above line 95/96,
the following test assertions are invalid.
----------------------------------------------------------------
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:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]