Home > Software engineering >  Hive Reading only one json row
Hive Reading only one json row

Time:12-05

I have a json like this

[{"event": "1", "meta": {"name":"Kumar","":"28"}}, {"event": "2", "meta": {"name":"Harsh","":"27"}}]

I removed the square bracket as in hive it is giving error org.apache.hadoop.hive.serde2.SerDeException: java.io.IOException: Start token not found where expected

{"event": "1", "meta": {"name":"Kumar","":"28"}}, {"event": "2", "meta": {"name":"Harsh","":"27"}}

I am creating my table like this

create external table record_two(event string,meta struct<name:string,age:string>)
ROW FORMAT SERDE 'org.apache.hcatalog.data.JsonSerDe'
LOCATION '/test/event_two/'; 

The table is created but when i run select it is only returning one record

CodePudding user response:

Records should be in separate lines in data file.

{"event": "1", "meta": {"name":"Kumar","age":"28"}}
{"event": "2", "meta": {"name":"Harsh","age":"27"}}

And no commas between records, only newline.

  • Related