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 63e105e12a720..d5d967c4a427b 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,12 @@ class GlutenClickhouseFunctionSuite extends GlutenClickHouseTPCHAbstractSuite { |""".stripMargin )(df => checkFallbackOperators(df, 0)) } + + test("GLUTEN-5981 null value from get_json_object") { + runQueryAndCompare( + """ + |SELECT get_json_object(a, '$.a') is null from values ('{"a": null}') as t(a) + |""".stripMargin + )(df => checkFallbackOperators(df, 0)) + } } diff --git a/cpp-ch/local-engine/Functions/SparkFunctionGetJsonObject.h b/cpp-ch/local-engine/Functions/SparkFunctionGetJsonObject.h index 6ba05e901791e..0619666926b27 100644 --- a/cpp-ch/local-engine/Functions/SparkFunctionGetJsonObject.h +++ b/cpp-ch/local-engine/Functions/SparkFunctionGetJsonObject.h @@ -113,6 +113,9 @@ 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()) {