json file to hive external table -


i have data in json format.

  1. correct

[{"text":"foo0","number":123},{"text":"foo1","number":345},{"text":"foo2","number":678},{"text":"foo3","number":901}]

  1. incorrect

{"text":"foo0","number":123}{"text":"foo1","number":345} {"text":"foo2","number":678}{"text":"foo3","number":901}

creating external table

create external table js_test_3 (   text string,   number string ) row format serde 'org.openx.data.jsonserde.jsonserde' location '/serde' 

then launch

select * js_test_3 

as result get

  1. correct json (retrieves many elements there rows)

text number

{"number":"123","text":"foo0"} {"number":"345","text":"foo1"}

  1. for incorrect json-(retrieves first element)

text number

foo0 123

how should write script creates list result correct?

text number

foo0 123

foo1 345

foo2 678

foo3 901

thanks

the jsonserde using expects input file 1 complete json per line. desirable because able split input (and divides works amongst worker nodes) on cr/lf.

if have well-formed json list show in "correct json" example, use tool jq transform input file expected format. example:

jq -c .[] correct.json > /serde-input.txt 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -