pythonboto3botoamazon-athenapyathena

How to specify file name when executing query via Athena API client (Boto3)?


I have a query string and using the start_query_execution() method, I'm right now able to run my query via Athena and get the results in the form of a CSV file in my S3 bucket.

However, the file's name is a bunch of random characters and I'd like to be able to give it a name in order to reference it in other applications (e.g. QuickSight).

From what I can see, the start_query_execution() method only contains the following parameters: QueryString, QueryExecutionContext, and ResultConfiguration in which I'm providing my S3 path.

How would I be able to give my query results file a specific name?


Solution

  • The file name is the Athena query ID. See Identifying Query Output Files. You can use that to pass on the S3 path or object name to other applications.

    Currently its not possible to give a custom name for the query results file. You could build a custom process around Athena queries to move and rename the S3 objects after the query completes.