-
Notifications
You must be signed in to change notification settings - Fork 116
Align the compliance-suite dialect registry with the entry points #905
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,12 @@ | ||
| import contextlib | ||
| import importlib.metadata | ||
| import re | ||
| import runpy | ||
| import textwrap | ||
| import uuid | ||
| from datetime import date, datetime | ||
| from decimal import Decimal | ||
| from pathlib import Path | ||
| from types import SimpleNamespace | ||
| from urllib.parse import quote_plus | ||
|
|
||
|
|
@@ -18,6 +21,7 @@ | |
| from sqlalchemy.sql.ddl import CreateTable | ||
| from sqlalchemy.sql.schema import Column, MetaData, Table | ||
| from sqlalchemy.sql.selectable import TextualSelect | ||
| from sqlalchemy.util import PluginLoader | ||
|
|
||
| from pyathena.aio.sqlalchemy.base import AthenaAioDialect | ||
| from pyathena.converter import DefaultTypeConverter | ||
|
|
@@ -122,6 +126,20 @@ def test_bare_scheme_uses_rest_driver(self): | |
| assert bare.url.get_driver_name() == "rest" | ||
| assert bare.dialect.dialect_description == "awsathena+rest" | ||
|
|
||
| def test_compliance_suite_registry_matches_entry_points(self, monkeypatch): | ||
| # tests/sqlalchemy registers the dialects for the compliance suite, and a | ||
| # registration overrides the installed entry point in that process. | ||
| loader = PluginLoader("sqlalchemy.dialects") | ||
| monkeypatch.setattr("sqlalchemy.dialects.registry", loader) | ||
| runpy.run_path(str(Path(__file__).parents[2] / "sqlalchemy" / "__init__.py")) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Independent review, relayed. Reviewer: Codex CLI 0.157.1, model gpt-6-sol, reasoning effort high, session 01a0f0e9-ceb7-7911-8021-a2fa694d6043. Static review in a read-only sandbox of a detached snapshot at head d6b9303 (base 8679f04); it received the literal diff without the PR description, commit message, or prior findings, and ran no tests. The snapshot and the PR worktree were unchanged afterwards. Covered: the two changed files, the Result: CLEAN. All 11 registrations match the entry points. The test locates the file from |
||
| entry_points = { | ||
| entry_point.name: entry_point.load() | ||
| for entry_point in importlib.metadata.entry_points(group="sqlalchemy.dialects") | ||
| if entry_point.value.startswith("pyathena.") | ||
| } | ||
| assert entry_points | ||
| assert {name: load() for name, load in loader.impls.items()} == entry_points | ||
|
|
||
| @pytest.mark.parametrize("dialect_class", [AthenaDialect, AthenaAioDialect]) | ||
| def test_type_compiler(self, dialect_class): | ||
| # SQLAlchemy 2.0 builds the type compiler from type_compiler_cls. A legacy | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,10 +7,11 @@ | |
|
|
||
| from sqlalchemy.dialects import registry | ||
|
|
||
| registry.register("awsathena", "pyathena.sqlalchemy.base", "AthenaDialect") | ||
| registry.register("awsathena", "pyathena.sqlalchemy.rest", "AthenaRestDialect") | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Self-review round one (implementation behavior). Base 8679f04, head d6b9303. Covered: both changed files; how Result: CLEAN.
|
||
| registry.register("awsathena.rest", "pyathena.sqlalchemy.rest", "AthenaRestDialect") | ||
| registry.register("awsathena.pandas", "pyathena.sqlalchemy.pandas", "AthenaPandasDialect") | ||
| registry.register("awsathena.arrow", "pyathena.sqlalchemy.arrow", "AthenaArrowDialect") | ||
| registry.register("awsathena.polars", "pyathena.sqlalchemy.polars", "AthenaPolarsDialect") | ||
| registry.register("awsathena.s3fs", "pyathena.sqlalchemy.s3fs", "AthenaS3FSDialect") | ||
| registry.register("awsathena.aiorest", "pyathena.aio.sqlalchemy.rest", "AthenaAioRestDialect") | ||
| registry.register("awsathena.aiopandas", "pyathena.aio.sqlalchemy.pandas", "AthenaAioPandasDialect") | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Self-review round two (claims, callers, operations). Base 8679f04, head d6b9303.
Claims checked:
PluginLoader.loadreturnsself.impls[name]()before it consults entry points. Reproduced: importingtests.sqlalchemyon master makes a bare URL createAthenaDialect; with this change it createsAthenaRestDialect.just testrecipes run the suites in separate processes, and the compliance suite connects only with+rest/+aiorest":justfilerunstests/pyathena/andtests/sqlalchemy/in separate pytest commands;tests/__init__.pybuilds only+rest/+aiorestURLs.sqlafilter (^tests/sqlalchemy/,^tests/pyathena/(aio/)?sqlalchemy/) and not thesparkone, so Ready runs the PyAthena suite without Spark plus both compliance suites.Callers: only test harness code changes; no library behavior or AWS request path changes.
Result: CLEAN after the PR body correction above.