提问人:Roelant 提问时间:11/16/2023 最后编辑:Guru StronRoelant 更新时间:11/16/2023 访问量:14
Athena 等效于 Presto 在数组列上的find_first_index
Athena equivalent for Presto's find_first_index on array column
问:
find_first_index(数组 (E) , 函数 (T, 布尔值)) → BIGINT#
返回数组的第一个元素的索引,该元素为 function(T,boolean) 返回 true。 如果不存在此类元素,则返回 NULL。
AWS Athena 中不存在此记录的 presto 函数。有没有好的选择?
答:
0赞
Guru Stron
11/16/2023
#1
Amazon Athena 基于 Presto 0.217(v.2 引擎 - 文档)或 Trino(v.3 引擎 - 文档),并在 Presto 0.280 中引入,在这两种情况下都不可用,但您可以通过组合和来模拟它(这可能不那么有效)。类似这些内容:find_first_index
find_first_index
array_position
transform
select array_position(
trasnform(array_col, el -> if(some_condition, 1, 0),
1
))
from ...
或
select array_position(
trasnform(array_col, el -> some_condition)
true
))
from ...
评论