linhongliu-db commented on code in PR #59882:
URL: https://github.com/apache/spark/pull/59882#discussion_r4449583057


##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/StringExpressionsSuite.scala:
##########
@@ -1640,6 +1641,31 @@ class StringExpressionsSuite extends SparkFunSuite with 
ExpressionEvalHelper {
       Literal.create(null, IntegerType), Literal.create(null, IntegerType)), 
null)
   }
 
+  for ((expression, expected) <- Seq(
+      (ToNumber(Literal("12"), Literal("99")), Decimal(12)),
+      (TryToNumber(Literal("12"), Literal("99")), Decimal(12)),
+      (ToCharacter(Literal(Decimal(12)), Literal("99")), "12"))) {
+    test(s"number format evaluator copies isolate parser state: 
${expression.prettyName}") {
+      checkEvaluation(expression, expected)
+      val first = expression.freshCopyIfContainsStatefulExpression()
+      val second = expression.freshCopyIfContainsStatefulExpression()
+      assert(first ne expression)
+      assert(second ne first)
+      assert(first.foldable == expression.foldable)

Review Comment:
   Addressed in af30df7, included in the current 18a4bbe head. The tests assert 
foldability directly, check that ConstantFolding produces the expected literal 
for each expression and fresh copy, and verify that attribute inputs remain 
nonfoldable and unchanged. The subsequent review confirmed the fix. The PR 
description now states the internal-hardening scope. CI passes.



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