This is an automated email from the ASF dual-hosted git repository.
zhangzc 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 85e8619f1 [GLUTEN-5981][CH] Make the result be null when the queried
field in get_json_object is null (#6001)
85e8619f1 is described below
commit 85e8619f124edbe73ded69efd2173b45c833c6c5
Author: lgbo <[email protected]>
AuthorDate: Fri Jun 7 18:57:52 2024 +0800
[GLUTEN-5981][CH] Make the result be null when the queried field in
get_json_object is null (#6001)
[CH] Make the result be null when the queried field in get_json_object is
null
---
.../gluten/execution/GlutenClickhouseFunctionSuite.scala | 11 +++++++++++
cpp-ch/local-engine/Functions/SparkFunctionGetJsonObject.h | 2 ++
2 files changed, 13 insertions(+)
diff --git
a/backends-clickhouse/src/test/scala/org/apache/gluten/execution/GlutenClickhouseFunctionSuite.scala
b/backends-clickhouse/src/test/scala/org/apache/gluten/execution/GlutenClickhouseFunctionSuite.scala
index 63e105e12..7e46a6989 100644
---
a/backends-clickhouse/src/test/scala/org/apache/gluten/execution/GlutenClickhouseFunctionSuite.scala
+++
b/backends-clickhouse/src/test/scala/org/apache/gluten/execution/GlutenClickhouseFunctionSuite.scala
@@ -179,4 +179,15 @@ class GlutenClickhouseFunctionSuite extends
GlutenClickHouseTPCHAbstractSuite {
|""".stripMargin
)(df => checkFallbackOperators(df, 0))
}
+
+ test("GLUTEN-5981 null value from get_json_object") {
+ spark.sql("create table json_t1 (a string) using parquet")
+ spark.sql("insert into json_t1 values ('{\"a\":null}')")
+ runQueryAndCompare(
+ """
+ |SELECT get_json_object(a, '$.a') is null from json_t1
+ |""".stripMargin
+ )(df => checkFallbackOperators(df, 0))
+ spark.sql("drop table json_t1")
+ }
}
diff --git a/cpp-ch/local-engine/Functions/SparkFunctionGetJsonObject.h
b/cpp-ch/local-engine/Functions/SparkFunctionGetJsonObject.h
index 6ba05e901..1d9b9a0fd 100644
--- a/cpp-ch/local-engine/Functions/SparkFunctionGetJsonObject.h
+++ b/cpp-ch/local-engine/Functions/SparkFunctionGetJsonObject.h
@@ -113,6 +113,8 @@ public:
JSONStringSerializer serializer(*col_str);
if (elements.size() == 1) [[likely]]
{
+ if (elements[0].isNull())
+ return false;
nullable_col_str.getNullMapData().push_back(0);
if (elements[0].isString())
{
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]