-
Notifications
You must be signed in to change notification settings - Fork 711
Description
Describe the bug
When using Athenas new managed query result storage in a workgroup instead of a self managed S3 bucket, the library still tries to set a custom bucket for Athena queries which fails with an error message:
botocore.errorfactory.InvalidRequestException: An error occurred (InvalidRequestException) when calling the StartQueryExecution operation: ManagedQueryResultsConfiguration and ResultConfiguration cannot be set together.
The issue seems to be that the s3 output location is always set, even when it's None. See this line of code:
"OutputLocation": _get_s3_output(s3_output=s3_output, wg_config=wg_config, boto3_session=boto3_session) |
If I comment out that one everything works with managed query result storage.
I thing if s3_location is empty the library should check once beforehand if managed output storage is active within the workgroup before auto creating the bucket (current behavior). Another idea would be an explicit option to enable the managed storage in the config, because another api call to check the workgroup may be to expensive.
AWS documentation links:
https://aws.amazon.com/about-aws/whats-new/2025/06/amazon-athena-managed-query-results-streamline-analysis-workflows
https://docs.aws.amazon.com/athena/latest/ug/managed-results.html
How to Reproduce
-
Enable the managed query result location in an Athena workgroup (see https://docs.aws.amazon.com/athena/latest/ug/managed-results.html)
-
Try to run a query like this:
import awswrangler as wr
x = wr.athena.read_sql_query(
"SELECT * FROM testing",
database="dev123",
)
- Get the error
botocore.errorfactory.InvalidRequestException: An error occurred (InvalidRequestException) when calling the StartQueryExecution operation: ManagedQueryResultsConfiguration and ResultConfiguration cannot be set together.
Expected behavior
No error
Your project
No response
Screenshots
No response
OS
Mac
Python version
3.12
AWS SDK for pandas version
3.10.1
Additional context
No response