hive implements json array disassembly

The middle field acquire_type of the PAYCHANNELDETAIL table is in the json format as follows
[{"payAmount":"375000","payChannelCode":"BOC"},{"payAmount":"376000","payChannelCode":"ABC"}]

The following is the data disassembly operation
select pay_order_id,tag1,bill_date
from (
select pay_order_id,substr(acquire_type,2,length(acquire_type)-2) tags,bill_date from dd.PAYCHANNELDETAIL
) ta  lateral view explode(split(tags, '},')) r1 as tag1
;

The query results are as follows:
1603150000007617360	{"payAmount":"375000","payChannelCode":"BOC"}	2016-03-15
1603150000007617360	{"payAmount":"376000","payChannelCode":"ABC"}	2016-03-15


json attribute disassembly
SELECT
pay_order_id,
get_json_object(subjson,'$.payAmount') as payAmount,
get_json_object(subjson,'$.payChannelCode') as payChannelCode,
bill_date
FROM
dd.PAYCHANNELDETAIL_SUBJSON

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326939104&siteId=291194637