Amazon AWS Athena -- Removing Temp Files

2k views Asked by At

Anyone know how to get rid of all the temporary files that get created in the S3 buckets when using Athena to query?

Is there some setting or option to disable these -- or criteria to filter how to remove them?

I'm using JDBC connection via linux to select from my S3 bucket.

1

There are 1 answers

1
John Rotenstein On BEST ANSWER

Amazon Athena creates files in Amazon S3 with the output of all Athena queries. This is beneficial, because the output can then be used in a subsequent process. Also, it could avoid the need to re-run queries which is useful because Athena is charged based on data scanned for each query.

If you do not wish to keep these output files, or if you wish to remove them after a period of time, the easiest method is to configure Object Lifecycle Management on the Amazon S3 bucket. Simply create an expiration policy that deletes the files after a certain number of days. The files will then be deleted each night (or thereabouts).

Amazon Athena lifecycle rules to clear logs