首页 > 解决方案 > 使用 AWS athena 从 avro 文件读取数组没有结果和未知错误

问题描述

我有几个 avro 文件存储在 S3 存储桶中,并让 AWS Glue 使用 AvroSerde 抓取它们,完美地粘合索引文件。

当我使用 AWS athena 像这样查询表时:select * from mytable我得到了预期的所有结果,并且“值”列显示为 [23.4,345.6] 例如。

但是,当我尝试选择“值”列(或尝试在其上使用任何数组函数)时,我没有得到任何结果,并且 Athena 中的查询选项卡显示“失败”图标,但是我没有收到任何错误。

失败的示例查询:select values from mytable

雅典娜的输出describe mytable;

timestamp               bigint                  from deserializer   
values                  array<float>            from deserializer   
account                 string                                      
year                    string                                      
month                   string                                      
day                     string                                      
hour                    string                                      
device                  string                                      
type                    string                                      

# Partition Information      
# col_name              data_type               comment             

account                 string                                      
year                    string                                      
month                   string                                      
day                     string                                      
hour                    string                                      
device                  string                                      
type                    string   

AWS Glue 中的表定义:

Name         mytable
Database     new_formats_test
Classification  avro
Location     s3://mytable/
Input format    org.apache.hadoop.hive.ql.io.avro.AvroContainerInputFormat
Output format   org.apache.hadoop.hive.ql.io.avro.AvroContainerOutputFormat
Serde serialization lib org.apache.hadoop.hive.serde2.avro.AvroSerDe
Serde parameters    
avro.schema.literal {"type":"record","name":"ArchiveDataEntry","namespace":"com.epihunter.data.archive","fields":[{"name":"timestamp","type":"long"},{"name":"values","type":{"type":"array","items":"float"}}]}serialization.format 1
Table properties    
sizeKey 18525162objectCount 1UPDATED_BY_CRAWLER Scan S3 new formats
avro.schema.literal {"type":"record","name":"ArchiveDataEntry","namespace":"com.epihunter.data.archive","fields":[{"name":"timestamp","type":"long"},{"name":"values","type":{"type":"array","items":"float"}}]}

标签: amazon-s3avroamazon-athenaaws-glue

解决方案


回答我自己的问题:values是导致失败的保留关键字。使用双引号"values"或明显重命名列可以解决问题


推荐阅读