我正在使用Presto,并且我的数据库有一个列,其中包含状态跟踪,其输入采用以下格式
Content of column to be parsed
{"{\"time\":\"2018-03-31T17:19:03.325+05:30\",\"status\":\"In Progress\",\"requested_by\":\"\",\"request_reason\":\"PTA completed in AMS\",\"old_status\":\"In Progress\",\"current_status\":\"Active\"}","{\"requested_by\":\"New\",\"request_reason\":\"\",\"time\":\"2018-03-31T20:48:28.034+05:30\",\"crs_id\":\"HLD024\",\"user_id\":282,\"old_status\":\"Active\",\"current_status\":\"Live\"}"}
我想捕获状态从活动状态变为活动状态的日期。 在R中编写SQL查询时,我可以使用-
select oyo_id,min(date)
from (select tab.* from( select h.my_id,
(unnest(h.status_track::text[])::json->>'old_status')::text as old_status,
(unnest(h.status_track::text[])::json->>'current_status')::text as
current_status,
date((unnest(h.status_track::text[])::json->>'time' ))
from hotels h
join taggings tg on tg.taggable_id = h.id
left join crs_enums e1 on e1.enum_key = h.status and e1.table_name
='hotels' and e1.column_name = 'status'
where tg.tag_name = 'my'
and h.status in (0,1,2,3,4)
and h.oyo_id not like '%my%') tab
where (old_status = 'Active' or current_status = 'Active') ) as a
group by 1
如何在Hive中进行解析以捕获状态从活动状态更改为活动状态后的日期。