awswrangler.athena.repair_table¶
- awswrangler.athena.repair_table(table: str, database: str | None = None, data_source: str | None = None, s3_output: str | None = None, workgroup: str = 'primary', encryption: str | None = None, kms_key: str | None = None, athena_query_wait_polling_delay: float = 1.0, boto3_session: Session | None = None) str¶
Run the Hive’s metastore consistency check: ‘MSCK REPAIR TABLE table;’.
Recovers partitions and data associated with partitions. Use this statement when you add partitions to the catalog. It is possible it will take some time to add all partitions. If this operation times out, it will be in an incomplete state where only a few partitions are added to the catalog.
Note
Create the default Athena bucket if it doesn’t exist and s3_output is None. (E.g. s3://aws-athena-query-results-ACCOUNT-REGION/)
- Parameters:
table (
str) – Table name.database (
str|None) – AWS Glue/Athena database name.data_source (
str|None) – Data Source / Catalog name. If None, ‘AwsDataCatalog’ is used.s3_output (
str|None) – AWS S3 path.workgroup (
str) – Athena workgroup. Primary by default.encryption (
str|None) – None, ‘SSE_S3’, ‘SSE_KMS’, ‘CSE_KMS’.kms_key (
str|None) – For SSE-KMS and CSE-KMS , this is the KMS key ARN or ID.athena_query_wait_polling_delay (
float) – Interval in seconds for how often the function will check if the Athena query has completed.boto3_session (
Session|None) – The default boto3 session will be used if boto3_session receiveNone.
- Return type:
str- Returns:
Query final state (‘SUCCEEDED’, ‘FAILED’, ‘CANCELLED’).
Examples
>>> import awswrangler as wr >>> query_final_state = wr.athena.repair_table(table='...', database='...')