-
Notifications
You must be signed in to change notification settings - Fork 116
Backport #839: Resolve the bare awsathena scheme to the REST dialect #903
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’ll 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 |
|---|---|---|
|
|
@@ -36,7 +36,7 @@ documentation = "https://pyathena.dev/" | |
| issues = "https://github.com/pyathena-dev/PyAthena/issues" | ||
|
|
||
| [project.entry-points."sqlalchemy.dialects"] | ||
| awsathena = "pyathena.sqlalchemy.base:AthenaDialect" | ||
| 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 d6fe836, head 68b25aa. Covered: all three changed files ( Result: CLEAN for this PR's scope.
Out of scope, pre-existing on master as well:
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. Repair follow-up, round-one perspective (implementation behavior). Range: The out-of-scope note above is now addressed by backporting #905 (commit d6b9303 on master's PR branch,
Result: CLEAN. |
||
| "awsathena.rest" = "pyathena.sqlalchemy.rest:AthenaRestDialect" | ||
| "awsathena.pandas" = "pyathena.sqlalchemy.pandas:AthenaPandasDialect" | ||
| "awsathena.arrow" = "pyathena.sqlalchemy.arrow:AthenaArrowDialect" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,11 @@ | ||
| 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 urllib.parse import quote_plus | ||
|
|
||
| import numpy as np | ||
|
|
@@ -15,7 +18,9 @@ | |
| 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.sqlalchemy.rest import AthenaRestDialect | ||
| from pyathena.sqlalchemy.types import ( | ||
| TINYINT, | ||
| AthenaArray, | ||
|
|
@@ -50,6 +55,33 @@ def unique_s3tables_table_name(base: str) -> str: | |
| return f"{base}_{uuid.uuid4().hex[:8]}" | ||
|
|
||
|
|
||
| class TestAthenaDialect: | ||
| def test_bare_scheme_uses_rest_driver(self): | ||
| # The bare awsathena entry point resolves to the REST dialect, like | ||
| # awsathena+rest. Requires the package to be reinstalled (uv sync) so the | ||
| # installed entry point metadata matches pyproject.toml. | ||
| url = "awsathena://athena.us-west-2.amazonaws.com:443/default?s3_staging_dir=s3://bucket/path/" | ||
| bare = create_engine(url) | ||
| assert type(bare.dialect) is 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. Independent review, relayed. Reviewer: Codex CLI 0.157.1, model gpt-6-sol, reasoning effort high, session 01a0f0d1-3da1-72c2-bd28-d4c093959025. Static review in a read-only sandbox of a detached snapshot at head 68b25aa (base d6fe836); 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 three changed files; sync and async dialect classes and entry points; test fixtures, SQLAlchemy registration, CI test selection, and repository conventions. It found that the new test fails against the old installed entry point, the docs row matches the new sync driver, async URLs keep Result: FINDINGS (1).
Author verification: confirmed. Importing
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 follow-up, relayed. Reviewer: Codex CLI 0.157.1, model gpt-6-sol, reasoning effort high, session 01a0f0fb-0a86-7de1-a945-130e9dd7cc0b. Static review in a read-only sandbox of a detached snapshot at bc5fc93, given the bounded diff 68b25aa..bc5fc93 and this thread's finding, without the PR description or author conclusions; no tests run. The snapshot and the PR worktree were unchanged afterwards. Covered: the two changed files, all eleven dialect entry points in Result: CLEAN. The finding above is resolved: bare |
||
| assert bare.driver == "rest" | ||
| 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")) | ||
| 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 | ||
|
|
||
|
|
||
| class TestSQLAlchemyAthena: | ||
| @pytest.mark.parametrize( | ||
| "engine", | ||
|
|
||
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 d6fe836, head 68b25aa.
Claims checked against evidence that could disprove them:
AthenaDialect, andEngine.driver,URL.get_driver_name(), anddialect_descriptioneach raiseAttributeError: reproduced by installingorigin/3.x(d6fe836) into an isolated environment with SQLAlchemy 2.0.46.TestAthenaDialectcame to master with Fix metadata reflection throttling and reuse listed metadata #777:git log -Sfinds 6d791e2, which GitHub maps to Fix metadata reflection throttling and reuse listed metadata #777.tests/__init__.py:6and:10useawsathena+rest:///awsathena+aiorest://, andtests/pyathena/conftest.py:158/:192default torest/aiorest. No other test or doc uses a bareawsathena://URL.-xsource and conflict resolution.Callers:
isinstance(engine.dialect, AthenaDialect)still holds, the cursor and connect arguments are unchanged, and SQLAlchemy 1.4.54 resolves the same class as 2.0.46. Onlytype(engine.dialect) is AthenaDialectchecks change, which the release note states.Operations: no AWS request path changes.
Corrections made to the PR body: "agreed for both lines" now states that the maintainer decided on the port. The CI note now says, from
.github/workflows/test.yaml:118-119, thatpyproject.tomlis a shared file, so Ready runs all three AWS suites, including Spark, on the newest Python version.Result: CLEAN after those wording corrections. The round-one out-of-scope note about
tests/sqlalchemy/__init__.pystands.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.
Repair follow-up, round-two perspective (claims, callers, operations), same range 68b25aa..bc5fc93.
Claims added to the PR body and commit message:
-xline names d6b9303, the single commit of Align the compliance-suite dialect registry with the entry points #905. Master merges PRs with merge commits, so that commit enters master's history when Align the compliance-suite dialect registry with the entry points #905 merges; the body now states that Align the compliance-suite dialect registry with the entry points #905 must merge first.tests/sqlalchemy/__init__.pyapplied without a conflict.Callers and operations: test harness only; no library behavior changes. CI selection is unchanged, because the
pyproject.tomlchange from #839 already selects all three suites including Spark.Result: CLEAN.