AWS athena table 空结果

AWS athena table empty result

我有一个 AWS athena table,其中包含由标准“Select * from...”查询返回的记录。我做了一个“show create table on this and say create a new table test2”。

test2 上的相同 select 查询总是 returns 空行。为什么会这样?

athena 中的表将数据保存在外部源中,在 aws 中是 S3。当您看到 ddl of create table 时,有一个 LOCATION 指向 S3 存储桶。如果 LOCATION 不同,这可能是您在 table.

上执行 select 时看不到任何行的原因
CREATE EXTERNAL TABLE `test_table`(
...
)
ROW FORMAT ...
STORED AS INPUTFORMAT ...
OUTPUTFORMAT ...
LOCATION s3://bucketname/folder/

如果位置正确,可能是您必须 运行 MSCK REPAIR TABLE command to update the metadata in the catalog after you add Hive compatible partitions. From the doc.

Use the MSCK REPAIR TABLE command to update the metadata in the catalog after you add Hive compatible partitions. The MSCK REPAIR TABLE command scans a file system such as Amazon S3 for Hive compatible partitions that were added to the file system after the table was created

确保也检查 Troubleshooting 部分。我曾经遗漏的一件事是关于我的 IAM 角色的 glue:BatchCreatePartition 政策。