當我執行 MSCK REPAIR TABLE 時,Amazon Athena 傳回分割區清單,但隨後無法將分割區新增至 AWS Glue Data Catalog 中的資料表。
簡短說明
以下是此行為的一些常見原因:
- AWS Identity and Access Management (IAM) 使用者或角色沒有允許 glue:BatchCreatePartition 動作的政策。
- Amazon Simple Storage Service (Amazon S3) 路徑採用駝峰式大小寫,而不是小寫 (例如,userId 而不是 userid)。
解決方法
IAM 政策中允許 glue:BatchCreatePartition
檢閱附加至您用來執行 MSCK REPAIR TABLE 之使用者或角色的 IAM 政策。當您 搭配 Athena 使用 AWS Glue Data Catalog時,IAM 政策必須允許glue:BatchCreatePartition 動作。如果政策不允許該動作,則 Athena 無法將分割區新增至中繼存放區。如需允許 glue:BatchCreatePartition 動作的 IAM 政策範例,請參閱 AmazonAthenaFullAccess 受管政策。
將 Amazon S3 路徑更改為小寫
Amazon S3 路徑名稱必須採用小寫字母。如果路徑採用駝峰式大小寫,則 MSCK REPAIR TABLE 無法將分割區新增至 AWS Glue Data Catalog。例如,如果 Amazon S3 路徑是 userId,則下列分割區無法新增至 AWS Glue Data Catalog:
- s3://awsdoc-example-bucket/path/userId=1/
- s3://awsdoc-example-bucket/path/userId=2/
- s3://awsdoc-example-bucket/path/userId=3/
要解決此問題,請採用小寫而不是駝峰式大小寫:
- s3://awsdoc-example-bucket/path/userid=1/
- s3://awsdoc-example-bucket/path/userid=2/
- s3://awsdoc-example-bucket/path/userid=3/
相關資訊
在 Athena 分割資料
Amazon Athena 的動作、資源和條件金鑰
AWS Glue 的動作、資源和條件金鑰