hive,
json
lateral view explode (split( regexp_replace(
112^A{"store": {"fruit":[{"weight":8,"type":"apple"},{"weight":9,"type":"pear"}], "bicycle":{"price":19.95,"color":"red"} }, "email":"amy@only_for_json_udf_test.net", "owner":"amy"}
select a.id,fruit from test a lateral view explode(split(regexp_replace(regexp_replace(get_json_object(a.name, '$.store.fruit'),'\\}\\,\\{','\\}\\;\\{'),'\\[|\\]',''),'\\;')) fruitTable as fruit ;
select b.id, count(*), count(distinct get_json_object(b.fruit, '$.weight')) from (select a.id,fruit from test a lateral view explode(split(regexp_replace(regexp_replace(get_json_object(a.name, '$.store.fruit'),'\\}\\,\\{','\\}\\;\\{'),'\\[|\\]',''),'\\;')) fruitTable as fruit )b group by b.id;
本站文章为和通数据库网友分享或者投稿,欢迎任何形式的转载,但请务必注明出处.
同时文章内容如有侵犯了您的权益,请联系QQ:970679559,我们会在尽快处理。