order_id order_type order_time
111 N 10:00111 A 10:05111 B 10:10
是用hql获取结果如下:
order_id order_type_1 order_type_2 order_time_1 order_time_2
111 N A 10:0010:05111 A B 10:0510:10createtableifnotexists order_type(
order_id string,
order_type string,
order_time string
)row format delimited fieldsterminatedby'\t'linesterminatedby'\n'
stored as textfile
;loaddatalocal inpath '/root/hivedata/order_type.txt'intotable order_type;select*from(select
order_id,
order_type type1,
lead(order_type)over(distribute by order_id sort by order_time) type2,
order_time time1,
lead(order_time)over(distribute by order_id sort by order_time) time2
from
order_type) tmp
where time2 isnotnull;