【发布时间】:2020-04-18 23:06:26
【问题描述】:
我有一个 .txt 文件,其中的列带有括号中的逗号分隔字符串数组,我想在 AWS Athena/QS 中对其进行一些分析。 原始数据如下所示:
col_id col2
1 ["string1", "string2", "string3", "string4"]
2 ["string1", "string2"]
3 ["string1", "string2", "string3"]
...
我在 Athena 中创建了一个表,其中包含以下内容:
create external table db.xx (
col1 string,
col2 array<string>
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'serialization.format' = ' ',
'field.delim' = ' ',
'collection.delim' = ','
) LOCATION 's3://xxx'
TBLPROPERTIES ("skip.header.line.count"="1");
表创建成功,列被识别为数组数据类型。
但是我无法访问数组中的元素。
从表中选择 element_at(col2,1) 返回:
string1, string2, string3, string4
string1, string2
string1, string2, string3
我也尝试从原始数据中删除 [] 和 "",但仍然得到相同的结果。
【问题讨论】:
标签: arrays amazon-athena amazon-quicksight