Skip to content

Commit

Permalink
fix 5981. make result be null when the feild is null
Browse files Browse the repository at this point in the history
  • Loading branch information
lgbo-ustc committed Jun 7, 2024
1 parent c23d28d commit 6cc104c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
2 changes: 2 additions & 0 deletions cpp-ch/local-engine/Functions/SparkFunctionGetJsonObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand Down

0 comments on commit 6cc104c

Please sign in to comment.