Tomme / dbt-athena

The athena adapter plugin for dbt (https://getdbt.com)
Apache License 2.0
140 stars 79 forks source link

[BUGFIX] Handle AWS API Error while deleting S3 objects #85

Closed Gatsby-Lee closed 1 year ago

Gatsby-Lee commented 2 years ago

This change prevents having duplicated data in a table ( incremental, insert_overwrite, partition ) that can be caused by missing permission.

Fixes #85

smoens commented 2 years ago

@Gatsby-Lee I seem to have a similar issue. I however don't know the best way to detect if my issue was caused by the same permission error. What permissions did you need to add to make sure no errors in the deletion of partitions are generated and how were you able to detect the error from the API side? Are there any logs I can check for this end? The debug log of dbt doesn't seem to give me any error with regard to the deletion of S3 objects.

Gatsby-Lee commented 2 years ago

@smoens you can add the change I made, then you can see the more detailed log OR, you can try a sample code that delete the partitions with your AWS Role.

import boto3

s3_resource = boto3.resource('s3')
s3_bucket = s3_resource.Bucket(bucket_name)
response = s3_bucket.objects.filter(Prefix=prefix).delete()
print(response)

The response result will tell you if there is any error

owenprough-sift commented 1 year ago

Typo in the first post: this PR addresses #84

Gatsby-Lee commented 1 year ago

moving to dbt-athena community version