我写 last_value(x) IGNORE NULLS over (partition by a order by b) 会报错 syntax error, error in :'IGNORE NULLS over (partition by 。。。。。
在Presto中,不支持直接在聚合函数后面使用IGNORE NULLS语法。要实现忽略NULL值的聚合,需要使用COALESCE函数处理NULL值,然后再使用聚合函数。例如,要实现LAST_VALUE聚合并忽略NULL值,可以使用以下SQL:
sql
SELECT
a,
LAST_VALUE(COALESCE(x, 0)) OVER (PARTITION BY a ORDER BY b) AS last_x
FROM ...
使用prestodb作为查询引擎,hive作为连接外部存储的元存储,基本上,你可以使用 lag(ignore nulls) / lead(ignore nulls) 以及一些插值算法