Skip to content
Advertisement

Athena query fails with boto3 (S3 location invalid)

I’m trying to execute a query in Athena, but it fails.

Code:

JavaScript

But it raises the following exception:

JavaScript

However, if I go to the Athena Console, go to Settings and enter the same S3 location (for example):

athena settings

the query runs fine.

What’s wrong with my code? I’ve used the API of several the other services (eg, S3) successfully, but in this one I believe I’m passing some incorrect parameters. Thanks.

Python: 3.6.1. Boto3: 1.4.4

Advertisement

Answer

EDIT: As suggested by Justin, AWS later added support for Athena by adding athena prefix to the bucket. Please upvote his answer.


Accepted Answer:

The S3 location provided to save your query results is invalid. Please check your S3 location is correct and is in the same region and try again.

Since it works when you use the console, it is likely the bucket is in a different region than the one you are using in Boto3. Make sure you use the correct region (the one that worked in the console) when constructing the Boto3 client. By default, Boto3 will use the region configured in the credentials file.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement