awswrangler.athena.repair_table

awswrangler.athena.repair_table(table: str, database: Optional[str] = None, s3_output: Optional[str] = None, workgroup: Optional[str] = None, encryption: Optional[str] = None, kms_key: Optional[str] = None, boto3_session: Optional[boto3.session.Session] = 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, optional) – AWS Glue/Athena database name.

  • s3_output (str, optional) – AWS S3 path.

  • workgroup (str, optional) – Athena workgroup.

  • encryption (str, optional) – None, ‘SSE_S3’, ‘SSE_KMS’, ‘CSE_KMS’.

  • kms_key (str, optional) – For SSE-KMS and CSE-KMS , this is the KMS key ARN or ID.

  • boto3_session (boto3.Session(), optional) – Boto3 Session. The default boto3 session will be used if boto3_session receive None.

Returns

Query final state (‘SUCCEEDED’, ‘FAILED’, ‘CANCELLED’).

Return type

str

Examples

>>> import awswrangler as wr
>>> query_final_state = wr.athena.repair_table(table='...', database='...')