AWS 雅典娜 将数组<数组<string>>转换为表



我有一个s3 bucket,里面有很多包含以下内容的文件:

{time:123456, state:{{1,2,3,4},{4,5,6,7}...}

在我使用Athena读取后,结果是具有2列的数据集:第一列是时间int,第二列是array<array<string>>,是否可以使用Athena sql将该表转换为:

select time, col1,col2,col3,col4
from table

col1…4是数组中列的名称时?

使用CROSS JOIN UNNEST取消测试上层数组:

select a.time, 
state_array[1] as col1, 
state_array[2] as col2,
state_array[3] as col3,
state_array[4] as col4
from my_table a
CROSS JOIN UNNEST(state) as t(state_array)

最新更新