Skip to content

Commit

Permalink
Hotfix - Explicit boto3 Region (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomme authored Oct 29, 2021
1 parent 6f32763 commit 3b0d2a8
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions dbt/adapters/athena/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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()

0 comments on commit 3b0d2a8

Please sign in to comment.