dcoliversun commented on code in PR #9009:
URL: https://github.com/apache/incubator-gluten/pull/9009#discussion_r2030486665
##########
backends-velox/src/test/scala/org/apache/gluten/execution/JsonFunctionsValidateSuite.scala:
##########
@@ -325,4 +326,64 @@ class JsonFunctionsValidateSuite extends
FunctionsValidateSuite {
}
}
}
+
+ test("json_object_keys function valid json format") {
+ withTempPath {
+ path =>
+ Seq[(String)](
+ (""""""),
+ ("""200"""),
+ ("""{}"""),
+ ("""{"key": 1}"""),
+ ("""{"key": "value", "key2": 2}"""),
+ ("""{"arrayKey": [1, 2, 3]}"""),
+ ("""{"key":[1,2,3,{"key":"value"},[1,2,3]]}"""),
+ ("""{"f1":"abc","f2":{"f3":"a", "f4":"b"}}"""),
+ ("""{"k1": [1, 2, {"key": 5}], "k2": {"key2": [1, 2]}}"""),
+ ("""[1, 2, 3]""")
+ )
+ .toDF("txt")
+ .write
+ .parquet(path.getCanonicalPath)
+
+
spark.read.parquet(path.getCanonicalPath).createOrReplaceTempView("tbl")
+
+ runQueryAndCompare("select txt, json_object_keys(txt) from tbl") {
+ checkSparkOperatorMatch[ProjectExecTransformer]
+ }
+
+ runQueryAndCompare(
+ "SELECT json_object_keys(null) " +
+ "from datatab limit 1;") {
+ checkGlutenOperatorMatch[ProjectExecTransformer]
+ }
+ }
+ }
+
+ test("json_object_keys function invalid json format") {
+ withTempPath {
+ path =>
+ Seq[(String)](
+ ("""{[1,2]}"""),
+ ("""{"key": 45, "random_string"}""")
+ )
+ .toDF("txt")
+ .write
+ .parquet(path.getCanonicalPath)
+
+
spark.read.parquet(path.getCanonicalPath).createOrReplaceTempView("tbl")
+
+ runQueryAndCompare("select txt, json_object_keys(txt) from tbl") {
+ checkSparkOperatorMatch[ProjectExecTransformer]
+ }
+ }
+ }
+
+ test("json_object_keys function no argument") {
+ intercept[AnalysisException] {
+ sql(
+ "SELECT json_object_keys()" +
+ "FROM datatab LIMIT 1");
Review Comment:
Sure, removed
--
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]