【Hive】解析json(get_json_object) https://blog.csdn.net/qq_34105362/article/details/80454697
lateral view:如果指定字段名则需要把lateral view查询出的列写到select中,才能在结果中出现;如果直接是select * 则自动会把lateral view查询出的列追加在后面。
select * from sales_info where dt = '2019-04-26'
----------------------------
select *,
get_json_object(state, '$.id') as id,
get_json_object(state, '$.token') as token,
get_json_object(state, '$.user_name') as user_name
from sales_info where dt = '2019-04-26';
----------------------------
select *
from sales_info
lateral view json_tuple(state,'id','token','user_name') state_json as id,token,user_name
where dt = '2019-04-26';
----------------------------
SELECT *
from
(select * from sales_info where dt = '2019-04-26') T1
lateral view json_tuple(state,'id','token','user_name') state_json as id,token,user_name
会自动把解析出的三个字段,添加到结果后面。