From 3b0d2a8bf58788958cc03427b7d75f9e411fffea Mon Sep 17 00:00:00 2001 From: Tom Date: Fri, 29 Oct 2021 14:12:12 +0100 Subject: [PATCH] Hotfix - Explicit boto3 Region (#39) --- dbt/adapters/athena/impl.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/dbt/adapters/athena/impl.py b/dbt/adapters/athena/impl.py index bde9c10f..ce524def 100644 --- a/dbt/adapters/athena/impl.py +++ b/dbt/adapters/athena/impl.py @@ -47,8 +47,11 @@ def clean_up_partitions( self, database_name: str, table_name: str, where_condition: str ): # Look up Glue partitions & clean up - glue_client = boto3.client('glue') - s3_resource = boto3.resource('s3') + conn = self.connections.get_thread_connection() + client = conn.handle + + glue_client = boto3.client('glue', region_name=client.region_name) + s3_resource = boto3.resource('s3', region_name=client.region_name) partitions = glue_client.get_partitions( # CatalogId='123456789012', # Need to make this configurable if it is different from default AWS Account ID DatabaseName=database_name, @@ -70,7 +73,9 @@ def clean_up_table( self, database_name: str, table_name: str ): # Look up Glue partitions & clean up - glue_client = boto3.client('glue') + conn = self.connections.get_thread_connection() + client = conn.handle + glue_client = boto3.client('glue', region_name=client.region_name) try: table = glue_client.get_table( DatabaseName=database_name, @@ -88,7 +93,7 @@ def clean_up_table( if m is not None: bucket_name = m.group(1) prefix = m.group(2) - s3_resource = boto3.resource('s3') + s3_resource = boto3.resource('s3', region_name=client.region_name) s3_bucket = s3_resource.Bucket(bucket_name) s3_bucket.objects.filter(Prefix=prefix).delete()