dongjoon-hyun commented on a change in pull request #27836: [SPARK-31009][SQL] 
Support json_object_keys function
URL: https://github.com/apache/spark/pull/27836#discussion_r405154076
 
 

 ##########
 File path: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/JsonExpressionsSuite.scala
 ##########
 @@ -790,4 +790,24 @@ class JsonExpressionsSuite extends SparkFunSuite with 
ExpressionEvalHelper with
         checkDecimalInfer(_, """struct<d:decimal(7,3)>""")
     }
   }
+
+  test("json_object_keys") {
+    Seq(
+      ("{}", Seq.empty[UTF8String]),
+      ("""{"key": 1}""", Seq("key")),
+      ("""{"key": "value", "key2": 2}""", Seq("key", "key2")),
+      ("""{"arrayKey": [1, 2, 3]}""", Seq("arrayKey")),
+      ("""{"key":[1,2,3,{"key":"value"},[1,2,3]]}""", Seq("key")),
+      ("""{"f1":"abc","f2":{"f3":"a", "f4":"b"}}""", Seq("f1", "f2")),
+      ("""{"k1": [1, 2, {"key": 5}], "k2": {"key2": [1, 2]}}""", Seq("k1", 
"k2")),
+      ("{[1,2]}", null),
+      ("""{"key": 45, "random_string"}""", null),
+      ("", null),
+      ("[]", null),
+      ("""[{"key": "JSON"}]""", null)
 
 Review comment:
   Could you sort the test cases a little meaningfully, please?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to