Update AWS Athena Based on new S3 Data

The company I work for backs up our DynamoDB tables into S3, and we need a (fairly minimal) way to do bespoke queries on our data in a way that Dynamo doesn’t support.

I was looking into Athena as a nice way to use our S3 backups as the source for our data warehouse / proto BI tool.

The question I couldn’t find the answer to is how are Athena tables ‘updated’ with new info?

If my backup S3 file is updated (via a stream, or daily) how does Athena ingest that new data? Do I have to run some sort of command? Do I need to delete the table and recreate it?

Any help or articles / documents relating to this would be helpful. Thanks!


Related discussions:

I think all you have to do is rerun the MSCK Repair command on the Athena table to get the new partitions in.

If the files are just in the same S3 folder, you dont need to update, it’s live updated.

If you add partitions, then you need to run the command as /u/dryless points out to add the partition.

Athena itself doesnt store data anywhere. it reads from s3, processes the query, writes the output. If you run the same query a second time, it rereads everything from s3 again, picking up any new changes. So, if the directory structure doesnt change, you dont have to do anything. If the locations of files change, then you potentially to recreate or re-partition it, depending on how you created and partitioned the data initially.

Athena doesn’t store the data. Athena “maps” a schema definition to your data as it sits on S3 and queries it live.

Others have mentioned that if your S3 data is partitioned that you would need to run the update command (MSCK REPAIR TABLE [tablename]), but if your dumping DynamoDB to to S3 using the datapipeline jobs, you won’t need to bother.

For your edification, you can run an Athena query, then run the DynamoDB backup and run the query again so see the difference.

I’ve been playing around a lot with Athena & spectrum. As others have said, yes it is a mapping of data stored in s3. Athena (and redshifted spectrum) are a re-implementation of EXTERNAL tables that Oracle popularized in the 90’s.

You need an OLAP database that allows for mutable data and maybe streaming upserts like StarRocks. You can store the data back on S3 or store with Apache Iceberg or Apache Hudi on S3.