我可以从雅典娜删除数据(表中的行)吗?

问题描述:

是否可以通过Athena查询删除S3中存储的数据?我必须从几个表中删除一些行(它们指向S3中的单独存储桶)。

Is it possible to delete data stored in S3 through an Athena query? I have some rows I have to delete from a couple of tables (they point to separate buckets in S3).

我在《雅典娜用户指南》中找不到解决方法: https://docs.aws.amazon.com/athena/latest/ug/athena-ug.pdf 不支持DELETE FROM ,但是我想知道是否有比尝试在S3中找到文件并删除它们更简单的方法。

I couldn't find a way to do it in the Athena User Guide: https://docs.aws.amazon.com/athena/latest/ug/athena-ug.pdf and DELETE FROM isn't supported, but I'm wondering if there is an easier way than trying to find the files in S3 and deleting them.

您可以利用Athena找出要删除的所有文件,然后分别删除它们。

You can leverage Athena to find out all the files that you want to delete and then delete them separately. There is a special variable "$path".

Select "$path" from <table> where <condition to get row of files to delete>

要使其自动化,您可以对Athena结果进行迭代,然后获取文件名并将其从S3中删除。

To automate this, you can have iterator on Athena results and then get filename and delete them from S3.