1

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

leftjoin
  • 36,950
  • 8
  • 57
  • 116
Kumar Harsh
  • 423
  • 5
  • 26

1 Answers1

1

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.

leftjoin
  • 36,950
  • 8
  • 57
  • 116
  • Its like thi only from sourec is ther any way to read it for single line or wirh extra braces – Kumar Harsh Dec 03 '21 at 17:31
  • @KumarHarsh- put original array, define table as `complex_col array>>`, use ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe' See examples here: https://github.com/rcongiu/Hive-JSON-Serde But in this case array will not be exploded. Serde can not produce more rows than it is in the file.... – leftjoin Dec 03 '21 at 17:52