From f08822edf1972f4abbd975aaca0ba2989a778c7f Mon Sep 17 00:00:00 2001 From: Seito Kasai Date: Fri, 3 Jun 2022 18:36:20 +0900 Subject: [PATCH] apply https://github.com/Tomme/dbt-athena/pull/56/files --- dbt/adapters/athena/impl.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/dbt/adapters/athena/impl.py b/dbt/adapters/athena/impl.py index 3773e7ae..805a49fd 100755 --- a/dbt/adapters/athena/impl.py +++ b/dbt/adapters/athena/impl.py @@ -1,6 +1,6 @@ import agate import re -import boto3 +import boto3.session from botocore.exceptions import ClientError from itertools import chain from threading import Lock @@ -58,11 +58,12 @@ def clean_up_partitions( ): # Look up Glue partitions & clean up conn = self.connections.get_thread_connection() - client = conn.handle + creds = conn.credentials + session = boto3.session.Session(region_name=creds.region_name, profile_name=creds.aws_profile_name) with boto3_client_lock: - glue_client = boto3.client('glue', region_name=client.region_name) - s3_resource = boto3.resource('s3', region_name=client.region_name) + glue_client = session.client('glue') + s3_resource = session.resource('s3') partitions = glue_client.get_partitions( # CatalogId='123456789012', # Need to make this configurable if it is different from default AWS Account ID DatabaseName=database_name, @@ -85,9 +86,10 @@ def clean_up_table( ): # Look up Glue partitions & clean up conn = self.connections.get_thread_connection() - client = conn.handle + creds = conn.credentials + session = boto3.session.Session(region_name=creds.region_name, profile_name=creds.aws_profile_name) with boto3_client_lock: - glue_client = boto3.client('glue', region_name=client.region_name) + glue_client = session.client('glue') try: table = glue_client.get_table( DatabaseName=database_name, @@ -105,7 +107,7 @@ def clean_up_table( if m is not None: bucket_name = m.group(1) prefix = m.group(2) - s3_resource = boto3.resource('s3', region_name=client.region_name) + s3_resource = session.resource('s3') s3_bucket = s3_resource.Bucket(bucket_name) s3_bucket.objects.filter(Prefix=prefix).delete()