cloud-fan commented on code in PR #57156:
URL: https://github.com/apache/spark/pull/57156#discussion_r3588302488


##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/variant/VariantExpressionSuite.scala:
##########
@@ -1495,4 +1495,111 @@ class VariantExpressionSuite extends SparkFunSuite with 
ExpressionEvalHelper {
       "VARIANT_SIZE_LIMIT",
       name => Map("sizeLimit" -> "16.0 MiB", "functionName" -> s"`$name`"))
   }
+
+  test("variant_array_append") {
+    def checkAppend(input: String, path: String, value: Expression, expected: 
String): Unit = {
+      val expr = VariantArrayAppend(
+        Literal(parseJson(input)), Literal.create(path, StringType), value)
+      checkEvaluation(
+        ResolveTimeZone.resolveTimeZones(Cast(expr, StringType)),
+        expected)
+    }
+
+    // Append to the root array, and to nested arrays reached through object 
keys / array indices.
+    checkAppend("[1, 2, 3]", "$", Literal(4), "[1,2,3,4]")
+    checkAppend("[]", "$", Literal("a"), """["a"]""")
+    checkAppend("""{"a": [1, 2]}""", "$.a", Literal(3), """{"a":[1,2,3]}""")
+    checkAppend("""{"a": [1], "b": 2}""", "$.a", Literal(9), 
"""{"a":[1,9],"b":2}""")
+    checkAppend("""{"a": [[0], [1, 2]]}""", "$.a[1]", Literal(9), 
"""{"a":[[0],[1,2,9]]}""")
+
+    // Non-numeric scalar values (boolean, floating point).
+    checkAppend("[1]", "$", Literal(true), "[1,true]")
+    checkAppend("[1]", "$", Literal(2.5), "[1,2.5]")
+
+    // An array value is cast to a variant and appended as a single element..

Review Comment:
   Nit: doubled period.
   ```suggestion
       // An array value is cast to a variant and appended as a single element.
   ```



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