#6/20/24 增加greatest函数:
select greatest(1,2,3,4,5,2)
结论:可以用hive presto spark得出正确的结果值
#6/20/24 增加last_value(cl1) ignore nulls over(order by ts ) as dt 函数:
有数据集:
1 | 1 | 1 |
2 | 2 |
|
3 | 3 |
|
4 | 4 | 3 |
5 | 5 | 5 |
6 | 6 |
|
需要把C2为空的值填充成上一行不为空的值
结果应该看起来是如下(黄色部分为程序添加内容):
序号 | c1 | c2 |
1 | 1 | 1 |
2 | 2 | 1 |
3 | 3 | 1 |
4 | 4 | 3 |
5 | 5 | 5 |
6 | 6 | 5 |
presto 程序:
select
c1,c2,last_value(c2) ignore nulls over(order by c1) as new_c2
from jdt_dev.ccc_xx order by c1
结果值:
序号 | c1 | c2 | new_c2 |
1 | 1 | 1 | 1 |
2 | 2 | 1 | |
3 | 3 | 1 | |
4 | 4 | 3 | 3 |
5 | 5 | 5 | 5 |
6 | 6 | 5 |