我使用了
fist_value
函数,它工作正常,但是当我添加“IGNORE NULLS”时,出现以下错误
第 1:179 行:输入“)”不匹配。期待:“结束”
我的功能:
first_value (if(DiffconvCompView = 0,null,DiffconvCompView) ignore nulls) OVER (partition by Widget_id, User_country, Domain order by date desc , hour desc ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING )
所以我查看了文档,语法看起来不错。
FIRST_VALUE | LAST_VALUE
( expression [ IGNORE NULLS | RESPECT NULLS ] ) OVER
(
[ PARTITION BY expr_list ]
[ ORDER BY order_list frame_clause ]
)
https://docs.aws.amazon.com/redshift/latest/dg/r_WF_first_value.html
那么为什么我会收到错误?
Athena 使用 Presto,而不是 Redshift,因此在
ignore nulls
的右大括号之后使用 first_value
:
first_value(if(DiffconvCompView = 0, null, DiffconvCompView)) ignore nulls OVER (...))