Resolve the bare awsathena scheme to the REST dialect - #839
Merged
laughingman7743 merged 4 commits intoSep 30, 2026
Merged
laughingman7743 merged 4 commits into
laughingman7743 merged 4 commits into
Conversation
The bare awsathena:// scheme resolves to AthenaDialect, which did not define a driver. SQLAlchemy reads the driver when describing a dialect, so Engine.driver, URL.get_driver_name() and dialect_description raised AttributeError for bare URLs, and tools enumerating dialect entry points could not use it. Give the base dialect the REST driver, which is what awsathena+rest:// already selects; the concrete dialects keep their own driver values.
laughingman7743
requested changes
Sep 26, 2026
Revert the default driver on the base AthenaDialect, which stays the shared base for the concrete dialects. Resolve the bare awsathena:// scheme to AthenaRestDialect through the entry point instead, and assert the resolved dialect type in the test.
laughingman7743
approved these changes
Sep 27, 2026
…efault-driver # Conflicts: # tests/pyathena/sqlalchemy/test_base.py
The bare awsathena entry point now resolves to AthenaRestDialect, so the Dialect & driver table lists rest for it.
aminghadersohi
marked this pull request as ready for review
September 30, 2026 04:15
Contributor
Author
|
@laughingman7743 since your approval: added the docs table row (257f3c3), merged |
laughingman7743
approved these changes
Sep 30, 2026
Member
|
Thanks for the fix, @aminghadersohi. This is merged into master, and the backport to the 3.x maintenance branch is #903. It will not be released right away. The next 3.x release will wait until a fix for #854 or #857 is in as well; both are small, so they should not hold it for long. |
laughingman7743
added a commit
that referenced
this pull request
Sep 30, 2026
…ntry points tests/sqlalchemy/__init__.py registers the dialects for the SQLAlchemy compliance suite, and a registration overrides the installed entry point in any process that imports it. After #839 pointed the bare awsathena entry point at AthenaRestDialect, the file still registered the base AthenaDialect, and it never registered awsathena.polars. Register the same classes as pyproject.toml, and add a test that compares the file's registrations with the installed entry points. (cherry picked from commit d6b9303) Conflict resolution: tests/pyathena/sqlalchemy/test_base.py conflicted because master's import block and the tests around TestAthenaDialect come from PRs that are not on 3.x. Only #905's own lines are applied: the importlib.metadata, runpy, Path, and PluginLoader imports and test_compliance_suite_registry_matches_entry_points, placed after test_bare_scheme_uses_rest_driver as on master. The added lines match #905's commit exactly. tests/sqlalchemy/__init__.py applies unchanged apart from context (3.x's copy has no license header). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
laughingman7743
added a commit
that referenced
this pull request
Sep 30, 2026
Backport #839: Resolve the bare awsathena scheme to the REST dialect
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.
WHAT
Point the bare
awsathenaSQLAlchemy entry point inpyproject.tomlatpyathena.sqlalchemy.rest:AthenaRestDialectinstead ofpyathena.sqlalchemy.base:AthenaDialect, add a unit test for the bareawsathena://scheme, and list the bare schema with therestdriver in the "Dialect & driver" table ofdocs/sqlalchemy.md. The baseAthenaDialectis unchanged (an earlier revision gave it a defaultdriver; that was reverted in 91fd175 per review). The branch hasmastermerged in (131e53f).WHY
The approach was agreed in the review thread on this PR: #839 (comment)
The bare
awsathenaentry point resolves toAthenaDialect, which defines nodriver. SQLAlchemy reads the driver when it describes a dialect, so with a bare URL:The same happens for
dialect_description, which SQLAlchemy uses in statement-cache logging. Resolving the bare scheme to a concrete dialect matches how SQLAlchemy's built-in dialects (postgresql://resolves toPGDialect_psycopg2) and other third-party dialects handle it. The docs already useawsathena+rest://as the default URL form, so a bare URL now behaves the same asawsathena+rest://. The otherawsathena.*entry points are unchanged.TEST
Tested commit: 257f3c3 (the entry point and test are unchanged from 91fd175; 131e53f merges
master, 257f3c3 is the docs row). Python 3.12.13, SQLAlchemy 2.0.46, dependencies fromuv.lock. All results are local runs; nothing contacted AWS.The entry point change only takes effect after the package is reinstalled, because SQLAlchemy resolves dialects from the installed entry point metadata, not from
pyproject.tomldirectly.uv sync -p 3.12, then, with dummyAWS_DEFAULT_REGION,AWS_ATHENA_S3_STAGING_DIR,AWS_ATHENA_WORKGROUP,AWS_ATHENA_SPARK_WORKGROUPand credentials sotests/__init__.pycan import,uv run pytest --noconftest tests/pyathena/sqlalchemy/test_base.py -k test_bare_scheme_uses_rest_driver:master'spyproject.tomlentry point (uv syncagain): 1 failed,AssertionError: assert <class 'pyathena.sqlalchemy.base.AthenaDialect'> is AthenaRestDialect.uv run pytest --noconftest tests/pyathena/sqlalchemy/test_base.py::TestAthenaDialect tests/pyathena/sqlalchemy/test_compiler.py tests/pyathena/sqlalchemy/test_types.py: 212 passed.just lint(license headers, ruff check, ruff format --check, mypy, cfn-lint): clean.just docs lint(markdownlint-cli20.18.1, run throughnpxbecausemiseis not installed here): 0 errors in 25 files.Not run: the AWS integration tests under
tests/pyathena/sqlalchemy/andjust test sqla. Per review they are not needed here, because every fixture connects with an explicitawsathena+rest:///awsathena+aiorest://URL and never resolves the bare scheme.