json file to hive external table -
i have data in json format.
- correct
[{"text":"foo0","number":123},{"text":"foo1","number":345},{"text":"foo2","number":678},{"text":"foo3","number":901}]
- 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
- correct json (retrieves many elements there rows)
text number
{"number":"123","text":"foo0"} {"number":"345","text":"foo1"}
- 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
Post a Comment