cloud-fan commented on a change in pull request #33142:
URL: https://github.com/apache/spark/pull/33142#discussion_r660903087



##########
File path: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/SubexpressionEliminationSuite.scala
##########
@@ -159,35 +156,34 @@ class SubexpressionEliminationSuite extends SparkFunSuite 
with ExpressionEvalHel
     equivalence1.addExprTree(ifExpr1)
 
     // `add` is in both two branches of `If` and predicate.
-    assert(equivalence1.getAllEquivalentExprs().count(_.size == 2) == 1)
-    assert(equivalence1.getAllEquivalentExprs().filter(_.size == 2).head == 
Seq(add, add))
+    assert(equivalence1.getAllExprStates().count(_.useCount == 3) == 1)
+    assert(equivalence1.getAllExprStates().filter(_.useCount == 3).head.expr 
eq add)
     // one-time expressions: only ifExpr and its predicate expression
-    assert(equivalence1.getAllEquivalentExprs().count(_.size == 1) == 2)
-    assert(equivalence1.getAllEquivalentExprs().filter(_.size == 
1).contains(Seq(ifExpr1)))
-    assert(equivalence1.getAllEquivalentExprs().filter(_.size == 
1).contains(Seq(condition)))
+    assert(equivalence1.getAllExprStates().count(_.useCount == 1) == 2)
+    assert(equivalence1.getAllExprStates().filter(_.useCount == 
1).exists(_.expr eq ifExpr1))
+    assert(equivalence1.getAllExprStates().filter(_.useCount == 
1).exists(_.expr eq condition))
 
     // Repeated `add` is only in one branch, so we don't count it.
     val ifExpr2 = If(condition, Add(Literal(1), Literal(3)), Add(add, add))
     val equivalence2 = new EquivalentExpressions
     equivalence2.addExprTree(ifExpr2)
 
-    assert(equivalence2.getAllEquivalentExprs(1).size == 0)
-    assert(equivalence2.getAllEquivalentExprs().count(_.size == 1) == 3)
+    assert(equivalence2.getAllExprStates(1).isEmpty)
+    assert(equivalence2.getAllExprStates().count(_.useCount == 1) == 3)
 
     val ifExpr3 = If(condition, ifExpr1, ifExpr1)
     val equivalence3 = new EquivalentExpressions
     equivalence3.addExprTree(ifExpr3)
 
-    // `add`: 2, `condition`: 2
-    assert(equivalence3.getAllEquivalentExprs().count(_.size == 2) == 2)
-    assert(equivalence3.getAllEquivalentExprs().filter(_.size == 
2).contains(Seq(add, add)))
-    assert(
-      equivalence3.getAllEquivalentExprs().filter(_.size == 
2).contains(Seq(condition, condition)))
+    // `ifExpr1`: 2, `condition`: 2, `add`: 2

Review comment:
       See https://github.com/apache/spark/pull/33142/files#r660899263
   
   `ifExpr1` is indeed a common subexpression




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