1

I've tried loading simple JSON records from a file into hive tables like as shown below. Each JSON record is in a separate line.

{"Industry":"Manufacturing","Phone":null,"Id":null,"type":"Account","Name":"Manufacturing"}
{"Industry":null,"Phone":"(738) 244-5566","Id":null,"type":"Account","Name":"Sales"}
{"Industry":"Government","Phone":null,"Id":null,"type":"Account","Name":"Kansas City Brewery & Co"}

But I couldn't find any serde to load the array of comma (,) separated JSON records into the hive table. Input is a file containing JSON records as shown below...

[{"Industry":"Manufacturing","Phone":null,"Id":null,"type":"Account","Name":"Manufacturing"},{"Industry":null,"Phone":"(738) 244-5566","Id":null,"type":"Account","Name":"Sales"},{"Industry":"Government","Phone":null,"Id":null,"type":"Account","Name":"Kansas City Brewery & Co"}]

Can someone suggest me a serde which can parse this JSON file?

Thanks

dtolnay
  • 9,621
  • 5
  • 41
  • 62
  • I am getting the second example (array of JSON records) from mulesoft application. I am unable to load this data onto hive tables using `serde`s. But when I tried with first example (each record in a separate row), the serde works fine – Sri Harsha Chennavajjala Mar 31 '17 at 10:13
  • This is the format that I get from the mulesoft application and I am sure that it is in the correct JSON format. Ref: https://adobe.github.io/Spry/samples/data_region/JSONDataSetSample.html – Sri Harsha Chennavajjala Mar 31 '17 at 12:38
  • Hive has been designed to process tables made of *records*, stored in huge *files*. What you get is a small *message* that is supposed to be processed by an application, and possibly streamed into a table. Just do that: build an app that streams messages into a Hive table. – Samson Scharfrichter Mar 31 '17 at 23:21

1 Answers1

-1

You can check this serde : https://github.com/rcongiu/Hive-JSON-Serde

Another related post : Parse json arrays using HIVE

Community
  • 1
  • 1
shants
  • 612
  • 1
  • 7
  • 12