rcongiu / Hive-JSON-Serde

Read - Write JSON SerDe for Apache Hive.
Other
733 stars 391 forks source link

string null vs null #208

Open mmerchant opened 6 years ago

mmerchant commented 6 years ago

Given a JSON file:

{
  "id": "1234",
  "timestamp": "2018-05-31 00:00:00",
  "foo": {
    "key1": null,
    "key2": "value"
  }
}

Using the following table create:

CREATE EXTERNAL TABLE test_table
(
    `id` string,
    `timestamp` timestamp,
    `foo` string
) ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe'
WITH SERDEPROPERTIES ("explicit.null"="true");

When querying using the JSON_EXTRACT_SCALAR functions the null is treated as a string "null" rather than null. For example the query below would return no results:

SELECT * FROM test_table WHERE JSON_EXTRACT_SCALAR(foo, '$.foo.key1') IS NULL