This is an automated email from the ASF dual-hosted git repository.

philo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-gluten.git


The following commit(s) were added to refs/heads/main by this push:
     new aa89601296 [GLUTEN-9008][VL] Support json_object_keys function (#9009)
aa89601296 is described below

commit aa89601296117dd31eee6441dd3ffa08b2edaab3
Author: Qian Sun <[email protected]>
AuthorDate: Tue Apr 8 09:21:44 2025 +0800

    [GLUTEN-9008][VL] Support json_object_keys function (#9009)
---
 .../org/apache/gluten/utils/CHExpressionUtil.scala |  3 ++-
 .../execution/JsonFunctionsValidateSuite.scala     | 30 ++++++++++++++++++++++
 .../gluten/expression/ExpressionMappings.scala     |  1 +
 .../apache/gluten/expression/ExpressionNames.scala |  1 +
 4 files changed, 34 insertions(+), 1 deletion(-)

diff --git 
a/backends-clickhouse/src/main/scala/org/apache/gluten/utils/CHExpressionUtil.scala
 
b/backends-clickhouse/src/main/scala/org/apache/gluten/utils/CHExpressionUtil.scala
index 2728b8c412..9cad2316f5 100644
--- 
a/backends-clickhouse/src/main/scala/org/apache/gluten/utils/CHExpressionUtil.scala
+++ 
b/backends-clickhouse/src/main/scala/org/apache/gluten/utils/CHExpressionUtil.scala
@@ -206,6 +206,7 @@ object CHExpressionUtil {
     WIDTH_BUCKET -> DefaultValidator(),
     MAKE_DATE -> DefaultValidator(),
     MAP_CONCAT -> DefaultValidator(),
-    ARRAY_APPEND -> DefaultValidator()
+    ARRAY_APPEND -> DefaultValidator(),
+    JSON_OBJECT_KEYS -> DefaultValidator()
   )
 }
diff --git 
a/backends-velox/src/test/scala/org/apache/gluten/execution/JsonFunctionsValidateSuite.scala
 
b/backends-velox/src/test/scala/org/apache/gluten/execution/JsonFunctionsValidateSuite.scala
index fc118a1e09..9abbe017a6 100644
--- 
a/backends-velox/src/test/scala/org/apache/gluten/execution/JsonFunctionsValidateSuite.scala
+++ 
b/backends-velox/src/test/scala/org/apache/gluten/execution/JsonFunctionsValidateSuite.scala
@@ -325,4 +325,34 @@ class JsonFunctionsValidateSuite extends 
FunctionsValidateSuite {
         }
     }
   }
+
+  test("json_object_keys function") {
+    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]"""),
+          ("""{[1,2]}"""),
+          ("""{"key": 45, "random_string"}"""),
+          (null.asInstanceOf[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]
+        }
+    }
+  }
 }
diff --git 
a/gluten-substrait/src/main/scala/org/apache/gluten/expression/ExpressionMappings.scala
 
b/gluten-substrait/src/main/scala/org/apache/gluten/expression/ExpressionMappings.scala
index b14401cb6e..6fb271b6d2 100644
--- 
a/gluten-substrait/src/main/scala/org/apache/gluten/expression/ExpressionMappings.scala
+++ 
b/gluten-substrait/src/main/scala/org/apache/gluten/expression/ExpressionMappings.scala
@@ -211,6 +211,7 @@ object ExpressionMappings {
     Sig[StructsToJson](TO_JSON),
     Sig[JsonToStructs](FROM_JSON),
     Sig[JsonTuple](JSON_TUPLE),
+    Sig[JsonObjectKeys](JSON_OBJECT_KEYS),
     // Hash functions
     Sig[Murmur3Hash](MURMUR3HASH),
     Sig[XxHash64](XXHASH64),
diff --git 
a/shims/common/src/main/scala/org/apache/gluten/expression/ExpressionNames.scala
 
b/shims/common/src/main/scala/org/apache/gluten/expression/ExpressionNames.scala
index 6c85aec447..02c7866080 100644
--- 
a/shims/common/src/main/scala/org/apache/gluten/expression/ExpressionNames.scala
+++ 
b/shims/common/src/main/scala/org/apache/gluten/expression/ExpressionNames.scala
@@ -238,6 +238,7 @@ object ExpressionNames {
   final val TO_JSON = "to_json"
   final val FROM_JSON = "from_json"
   final val JSON_TUPLE = "json_tuple"
+  final val JSON_OBJECT_KEYS = "json_object_keys"
 
   // Hash functions
   final val MURMUR3HASH = "murmur3hash"


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

Reply via email to