Skip to content

Expose Managed Query Results configuration on Connection/Cursor #709

@laughingman7743

Description

@laughingman7743

Summary

Athena's Managed Query Results (GA 2025-06) lets a workgroup store query results in Athena-owned storage instead of a user-managed S3 bucket. When a workgroup has ManagedQueryResultsConfiguration.Enabled = true, callers do not need to pass an OutputLocation (and indeed cannot — workgroups with managed results reject ResultConfiguration.OutputLocation).

PyAthena currently always requires s3_staging_dir (or workgroup-overridden OutputLocation) to construct the ResultConfiguration for StartQueryExecution. This blocks users on managed-results workgroups.

Proposed change

  1. Relax the s3_staging_dir requirement in Connection.__init__ / BaseCursor when the workgroup uses managed results. The simplest path is to allow s3_staging_dir=None and skip ResultConfiguration.OutputLocation in the request when not provided. Athena will respond with an error if the workgroup actually requires one.
  2. (Optional) Surface the workgroup's managed-results setting via the existing AthenaQueryExecution.managed_query_results_enabled property added in Add support for newer GetQueryExecution response fields in AthenaQueryExecution #707 / feat: support newer GetQueryExecution response fields #708 for observability.

Reference: result_reuse_enabled / result_reuse_minutes is the existing precedent for an opt-in feature flowing through Connection -> BaseCursor._build_start_query_execution_request (see pyathena/common.py:208).

Out of scope

  • Workgroup creation / management (not part of PyAthena's surface).
  • Reading results from managed storage — GetQueryResults works transparently in both modes.

References

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions