Skip to content

Refactor shared execute() kwargs handling across cursor implementations #691

@laughingman7743

Description

@laughingman7743

Summary

Multiple cursor classes (sync/async + pandas/arrow/polars/s3fs) duplicate the same execute() argument handling for parameters like result_set_type_hints, result_reuse_enable, paramstyle, etc. Each new parameter added to execute() requires updating 11+ cursor files.

Proposal

Extract shared execute() kwargs into an ExecuteOptions dataclass or mixin to:

  • Reduce duplication across cursor implementations
  • Make it easier to add new execute() parameters in the future
  • Centralize parameter validation and documentation

Affected files

  • pyathena/cursor.py
  • pyathena/async_cursor.py
  • pyathena/aio/cursor.py
  • pyathena/pandas/cursor.py, pyathena/pandas/async_cursor.py
  • pyathena/arrow/cursor.py, pyathena/arrow/async_cursor.py
  • pyathena/polars/cursor.py, pyathena/polars/async_cursor.py
  • pyathena/s3fs/cursor.py, pyathena/s3fs/async_cursor.py

Definition of Done

  • Adding a new execute() argument requires changes in 1-2 files (not 11+)
  • sync/async + pandas/arrow/polars/s3fs cursors share the same validation logic (type checks, mutual exclusion, default resolution)
  • execute() argument documentation lives in a single source (dataclass/mixin docstring) rather than being duplicated per cursor

Context

Identified during PR review of result_set_type_hints feature (#690). Scoped out to keep the initial PR focused on core functionality.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions