View a markdown version of this page

Work with query results - Amazon Athena

Work with query results

Amazon Athena automatically stores the query results and query result metadata of each query that runs in a DuckDB workgroup.

DuckDB workgroups offer two options for query results. By default, Athena manages query results for you. Athena handles storage, encryption, and cleanup, so you don't need to configure a results bucket. It deletes results automatically after 24 hours. With managed query results, you can read results with the GetQueryResults API or stream them in Apache Arrow format with the GetQueryResultStream API.

Alternatively, you can store query results in your own Amazon S3 bucket (a customer managed bucket). With your own bucket, you control storage, permissions, lifecycle policies, and retention. You manage the bucket yourself. You can read results stored in your bucket with the GetQueryResults API or by reading the result files directly. You can't use GetQueryResultStream for results stored in your own bucket. GetQueryResults returns the same values whichever storage option you use.

You grant IAM permissions for GetQueryResults and GetQueryResultStream separately. To read query results, IAM principals need permission for the API that they use on the workgroup. If you store results in your own bucket, principals with Amazon S3 GetObject permission on the query result location can read the result files even if permission for GetQueryResults is denied.