hive 获取数组的最大值和最小值

2022-01-07 13:53:08 浏览数 (1)

1、首先把数组打散,生成中间表YYY

select exploded_column,XXXX.column2 from XXXX LATERAL VIEW explode(XXXX.column1) t1 as exploded_column

2、使用first_value获取最小值,last_value获取最大值

代码语言:javascript复制
select uid,point_id,
first_value(loc_x)over(partition by uid order by point_id) as start,
last_value(loc_x)over(partition by uid order by point_id rows between unbounded preceding and unbounded following) as end
from YYY;

0 人点赞