【发布时间】:2017-06-07 16:17:10
【问题描述】:
我正在尝试按年、月和日对 amazon athena 查询的数据进行分区。但是,当我尝试从分区数据中查询时,我无法获得任何记录。我按照blog 帖子中的说明进行操作。
创建表查询:
CREATE external TABLE mvc_test2 (
ROLE struct<Scope: string, Id: string>,
ACCOUNT struct<ClientId: string, Id: string, Name: string>,
USER struct<Id: string, Name: string>,
IsAuthenticated INT,
Device struct<IpAddress: string>,
Duration double,
Id string,
ResultMessage string,
Application struct<Version: string, Build: string, Name: string>,
Timestamp string,
ResultCode INT
)
Partitioned by(year string, month string, day string)
ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe'
LOCATION 's3://firehose-titlesdesk-logs/Mvc/'
表创建成功,结果信息说:
"查询成功。如果你的表有分区,需要加载这些 分区以便能够查询数据。您可以加载所有 分区或单独加载它们。如果您使用所有负载 partitions (MSCK REPAIR TABLE) 命令,分区必须是格式 被 Hive 理解。了解更多。”
跑步
msck repair table mvc_test2;
我得到了结果:
"分区不在 元存储:mvc_test2:2017/06/06/21 mvc_test2:2017/06/06/22"
此时,我尝试查询表时没有得到任何结果。
日志按年/月/日/小时以子文件夹格式存储。 例如:'s3://firehose-application-logs/process/year/month/day/hour'
如何正确分区数据?
【问题讨论】:
-
"如果您使用加载所有分区 (MSCK REPAIR TABLE) 命令,分区必须采用 Hive 可以理解的格式"
标签: amazon-web-services hive presto amazon-athena