AthenaにてShow partitionsが失敗する


現象

AWS Athenaにて特定テーブルのパーティションが多い場合、Show Partitionsにて、
パーティションの一覧を取得しようとすると、internal errorで失敗することがあります。

SHOW PARTITIONS {database}.{table_name}

Your query has the following error(s):

[ErrorCode: INTERNAL_ERROR_QUERY_ENGINE] Amazon Athena an experienced an internal error while executing this query. Please contact AWS support for further assistance. You will not be charged for this query. We apologize for the inconvenience.
This query ran against the "xxx" database, unless qualified by the query. Please post the error message on our forum or contact customer support with Query Id: xxxxxxxx-50d3-4699-ae41-XXXXXXXXXXXX.

テーブルのパーティションの数が多い場合に発生することがあるようです。
このテーブルに対して、MSCK REPAIR TABLEを実行しても同じくエラーとなります。

AWSサポートに問い合わせたところ、AWS側の不具合との回答でした。(2020/07/02時点)

回避策

回避策としては、GlueのDataCatalogと統合されている場合には、
Glue側でパーティションの一覧を取得することができます。

Glueと統合されているケースは、基本Glue側のAPIを使用して、パーティションの更新等を実施するのが良さそうですね。