繁体   English   中英

aws athena 转换数组<array<string> &gt; 到餐桌</array<string>

[英]aws athena convert array<array<string>> to table

我有一个 s3 存储桶,其中包含很多包含以下内容的文件:

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

在我使用 Athena 读取它之后,结果是具有 2 个列的数据集:第一个是 time 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)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM