Add native asyncio specialized cursors and DRY refactors (Phase 2)#667
Merged
laughingman7743 merged 7 commits intomasterfrom Feb 20, 2026
Merged
Add native asyncio specialized cursors and DRY refactors (Phase 2)#667laughingman7743 merged 7 commits intomasterfrom
laughingman7743 merged 7 commits intomasterfrom
Conversation
Phase 2 of native asyncio cursor support: - DRY: Add _pre_fetch flag to AthenaResultSet.__init__ to eliminate duplicated field initialization in AthenaAioResultSet - DRY: Extract _prepare_query() from BaseCursor._execute so both sync and async _execute share non-I/O query preparation logic - Add async metadata operations (list_databases, get_table_metadata, list_table_metadata) to AioBaseCursor - Add AioPandasCursor, AioArrowCursor, AioPolarsCursor using asyncio.to_thread() for result set creation (no new result set classes needed since fetch methods are in-memory only) - Add comprehensive tests for all new cursors and metadata ops Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move aio_pandas_cursor, aio_arrow_cursor, aio_polars_cursor fixtures from inline test definitions to tests/pyathena/aio/conftest.py, and re-export them via conftest.py in each test subpackage so pytest can discover them across directory boundaries. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Relocate specialized aio cursors from pyathena/{pandas,arrow,polars}/
to pyathena/aio/{pandas,arrow,polars}/ to keep all asyncio code
isolated under the aio package. This provides clearer separation
between sync and async implementations.
- pyathena/pandas/aio_cursor.py -> pyathena/aio/pandas/cursor.py
- pyathena/arrow/aio_cursor.py -> pyathena/aio/arrow/cursor.py
- pyathena/polars/aio_cursor.py -> pyathena/aio/polars/cursor.py
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move aio cursor tests from tests/pyathena/{pandas,arrow,polars}/ to
tests/pyathena/aio/{pandas,arrow,polars}/ to mirror the source package
structure. This also removes the re-export conftest.py files since the
fixtures in tests/pyathena/aio/conftest.py are now naturally in scope.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add Google-style docstrings to close, executemany, cancel, fetchone, fetchmany, and fetchall methods in AioPandasCursor, AioArrowCursor, and AioPolarsCursor, matching the level of documentation in AioCursor. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Extract `_build_get_table_metadata_request` in BaseCursor for consistent request construction between sync and async - Update async `_get_table_metadata` to use the new builder - Add test_description and test_description_initial to all aio specialized cursors (pandas, arrow, polars) - Add test_cancel_initial to verify ProgrammingError on fresh cursor - Add test_executemany_fetch to verify state reset after executemany Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…init__.py Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This was referenced Feb 20, 2026
laughingman7743
added a commit
that referenced
this pull request
Feb 21, 2026
Add comprehensive documentation for the native asyncio cursor implementations added in PRs #666, #667, #668. This includes a new docs/aio.md overview page, AioCursor sections in each specialized cursor page, API reference for the aio module, and an async example in the README. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This was referenced Feb 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 2 of native asyncio cursor support (follows #666).
Tracks #662 — S3FS/Spark cursors, boilerplate deduplication, and documentation remain for Phase 3.
DRY refactors
_pre_fetchflag toAthenaResultSet.__init__to eliminate ~25 lines of duplicated field initialization inAthenaAioResultSet_prepare_query()helper shared by sync/async_execute_build_get_table_metadata_request()helper shared by sync/async_get_table_metadataAsync metadata operations
list_databases,get_table_metadata,list_table_metadatatoAioBaseCursorSpecialized async cursors
AioPandasCursor,AioArrowCursor,AioPolarsCursorusingasyncio.to_thread()for result set creationpyathena/aio/package hierarchy for clear separationFiles changed
pyathena/result_set.py— add_pre_fetchparampyathena/common.py— extract_prepare_query(),_build_get_table_metadata_request()pyathena/aio/result_set.py— simplify__init__viasuper()pyathena/aio/common.py— use_prepare_query()/_build_get_table_metadata_request(), add metadata opspyathena/aio/pandas/__init__.py,cursor.pypyathena/aio/arrow/__init__.py,cursor.pypyathena/aio/polars/__init__.py,cursor.pytests/pyathena/aio/conftest.py— centralized fixtures for all aio cursorstests/pyathena/aio/test_cursor.py— add metadata teststests/pyathena/aio/pandas/__init__.py,test_cursor.pytests/pyathena/aio/arrow/__init__.py,test_cursor.pytests/pyathena/aio/polars/__init__.py,test_cursor.pyTest plan
make fmt && make chkpasses (lint, format, mypy)tests/pyathena/aio/test_cursor.pytests still passtest_list_databases,test_get_table_metadata,test_list_table_metadata)AioPandasCursortests pass (fetch, as_pandas, description, cancel, executemany, unload, context manager)AioArrowCursortests pass (fetch, as_arrow, as_polars, description, cancel, executemany, unload, context manager)AioPolarsCursortests pass (fetch, as_polars, as_arrow, description, cancel, executemany, unload, context manager)🤖 Generated with Claude Code