peter-toth commented on a change in pull request #33281:
URL: https://github.com/apache/spark/pull/33281#discussion_r667363268



##########
File path: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/SubexpressionEliminationSuite.scala
##########
@@ -323,6 +323,34 @@ class SubexpressionEliminationSuite extends SparkFunSuite 
with ExpressionEvalHel
     assert(commonExprs.head.expr eq add3)
   }
 
+  test("SPARK-36073: SubExpr elimination should include common child exprs of 
conditional " +
+    "expressions") {
+    val add = Add(Literal(1), Literal(2))
+    val ifExpr1 = If(Literal(true), add, Literal(3))
+    val ifExpr3 = If(GreaterThan(add, Literal(4)), Add(ifExpr1, add), 
Multiply(ifExpr1, add))
+
+    val equivalence = new EquivalentExpressions
+    equivalence.addExprTree(ifExpr3)
+
+    val commonExprs = equivalence.getAllExprStates(1)
+    assert(commonExprs.size == 1)
+    assert(commonExprs.head.useCount == 2)
+    assert(commonExprs.head.expr eq add)
+  }
+
+  test("SPARK-36073: Transparently canonicalized expressions are not necessary 
subexpressions") {
+    val add = Add(Literal(1), Literal(2))
+    val transparent = PromotePrecision(add)
+
+    val equivalence = new EquivalentExpressions
+    equivalence.addExprTree(transparent)

Review comment:
       Yes, maybe I could rephrase this if it doesn't make sense.




-- 
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]

Reply via email to