peter-toth commented on code in PR #40473:
URL: https://github.com/apache/spark/pull/40473#discussion_r1142068268


##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/SubexpressionEliminationSuite.scala:
##########
@@ -449,6 +449,20 @@ class SubexpressionEliminationSuite extends SparkFunSuite 
with ExpressionEvalHel
     assert(e2.getCommonSubexpressions.size == 1)
     assert(e2.getCommonSubexpressions.head == add)
   }
+
+  test("SPARK-42851: Handle supportExpressions consistently across add and 
get") {
+    val tx = {
+      val arr = Literal(Array(1, 2))
+      val ArrayType(et, cn) = arr.dataType
+      val lv = NamedLambdaVariable("x", et, cn)
+      val lambda = LambdaFunction(lv, Seq(lv))
+      ArrayTransform(arr, lambda)
+    }
+    val equivalence = new EquivalentExpressions
+    val isNewExpr = equivalence.addExpr(tx)

Review Comment:
   `.addExpr()`'s boolean result is counter-intuitive to other collection's 
`.add()` methods so IMO `isNewExpr` should be `!equivalence.addExpr(tx)` here. 
This is the reasons why I think getting rid of `.addExpr()` is probably the 
most straightforward fix here: https://github.com/apache/spark/pull/40488



-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to