rcongiu / Hive-JSON-Serde

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

Nested json #115

Closed nal33 closed 9 years ago

nal33 commented 9 years ago

My data is:- {VALUES:[{"UTAGID":"SYSTEM_CHILLER1","tagName":"P1","tagValue":"10","tagTime":"2015-07-23T14:29:30.731Z","tagQuality":"128"}' ...........}]};

create table t1(VALUES array<<struct<UTAGID:STRING, tagName:STRING, tagValue:STRING, tagTime:STRING, tagQuality:STRING>>) ROW FORMAT SERDE "org.apache.hadoop.hive.contrib.serde2.JsonSerde" STORED AS TEXTFILE; LOAD DATA LOCAL INPATH "/tmp/jsonstreaming.json" into table t1;

I'm using Oracle BigDataApplite software..so instead of maven i directly added the jar files...still getting ParseException error..what could be the reason?

rcongiu commented 9 years ago

well, for starters, you're not using my serde: ROW FORMAT SERDE "org.apache.hadoop.hive.contrib.serde2.JsonSerde" instead of ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe'. Second, you're not defining the struct inside the array, it should be

CREATE TABLE t1(
   values array<struct<utagid:string,tagname:string,tagvalue:int,tagtime:string,tagquality:int>> )
ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe'
...
nal33 commented 9 years ago

i tried using ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe' and defining the struct as you have said..create table(values array<struct<..... but when i ran the query select * from t1, i'm getting the values as null..