From 6cc104c7e902a15c9fbe73602d23f2bccda63459 Mon Sep 17 00:00:00 2001 From: lgbo-ustc Date: Thu, 6 Jun 2024 10:26:31 +0800 Subject: [PATCH] fix 5981. make result be null when the feild is null --- .../execution/GlutenClickhouseFunctionSuite.scala | 11 +++++++++++ .../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 63e105e12a72..7e46a6989d6f 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 6ba05e901791..1d9b9a0fd4c1 100644 --- a/cpp-ch/local-engine/Functions/SparkFunctionGetJsonObject.h +++ b/cpp-ch/local-engine/Functions/SparkFunctionGetJsonObject.h @@ -113,6 +113,8 @@ class GetJsonObjectImpl 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()) {