Skip to content

Comments

Extract shared boilerplate from sync cursors into WithFetch mixin#676

Merged
laughingman7743 merged 1 commit intomasterfrom
feature/669-with-fetch-mixin
Feb 21, 2026
Merged

Extract shared boilerplate from sync cursors into WithFetch mixin#676
laughingman7743 merged 1 commit intomasterfrom
feature/669-with-fetch-mixin

Conversation

@laughingman7743
Copy link
Member

Summary

  • Add WithFetch mixin to pyathena/result_set.py — the sync counterpart to WithAsyncFetch — consolidating shared properties (arraysize, result_set, query_id, rownumber, rowcount), lifecycle methods (close(), executemany(), cancel()), and fetch methods (fetchone(), fetchmany(), fetchall()) into a single base class
  • Refactor Cursor, PandasCursor, ArrowCursor, PolarsCursor, and S3FSCursor to inherit from WithFetch instead of the triple (BaseCursor, CursorIterator, WithResultSet), removing ~500 lines of duplicated code
  • Fix async_cursor.py import to use canonical pyathena.common.BaseCursor path

Design decisions

  • Placement in result_set.py: Avoids circular import (common.pyresult_set.pycommon.py) since result_set.py already imports CursorIterator from common.py
  • Simple arraysize validation (value <= 0 only) in WithFetch, matching WithAsyncFetchCursor and AioCursor override with strict validation (value > DEFAULT_FETCH_SIZE)
  • Out of scope: SparkCursor (different execution model), async cursors (separate concern), aio cursors (already deduplicated via WithAsyncFetch)

Closes #669

Test plan

  • make fmt — formatting clean
  • make chk — ruff lint + mypy type checking pass
  • make test — unit tests (requires AWS env)

🤖 Generated with Claude Code

Add WithFetch class to result_set.py as the sync counterpart to
WithAsyncFetch, consolidating ~500 lines of duplicated properties,
lifecycle methods, and fetch methods from 5 sync cursor types.

Closes #669

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@laughingman7743 laughingman7743 marked this pull request as ready for review February 21, 2026 07:16
@laughingman7743 laughingman7743 merged commit e75cd23 into master Feb 21, 2026
5 checks passed
@laughingman7743 laughingman7743 deleted the feature/669-with-fetch-mixin branch February 21, 2026 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extract shared boilerplate from sync cursors into WithFetch mixin

1 participant