Reply
New Contributor
Posts: 1
Registered: ‎01-20-2018

JSON to hive table - displaying nulls

Hi,

 

A Hive table (example: Table1) has a column ( column1) which is of struct type. This struct has a JSON-column which needs to converted to a hive table. ( JSON column data needs to be flattened and displayed in a hive view)

 

sample json

 

Table1:

{

id : " "

 

column1 :

{

json-column:

{

claim-number : "123"

claim-description : "test data"

}

 

}

 

The select query to display the json data is below

 

create view as

select

get_json_object(table1.column1.json-column, $.claim-number),

get_json_object(table1.column1.json-column, $.claim-description)

from table1

 

The result set is all null.

 

can you please suggest.

 

Thanks.

 

 

 

Cloudera Employee
Posts: 28
Registered: ‎11-20-2015

Re: JSON to hive table - displaying nulls

Each JSON record must be on a single line (no new-line characters allowed).

 

A return of 'null' just means that Hive cannot parse the JSON as directed.

Announcements