Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 45 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,49 @@ jobs:
tool: just
- run: just test offline

# The SQLAlchemy tests that need no AWS, and the collection of the compliance
# suites, on the latest release of each supported SQLAlchemy series; the
# offline job above runs the dialect tests on the locked version,
# and the AWS suites run the compliance suites on it. The AWS suites
# do not wait for this job, so a new SQLAlchemy release that breaks it does
# not stop the AWS suites of unrelated pull requests. The Release workflow
# requires it, as it requires every job of this workflow.
offline-sqla:

Copy link
Copy Markdown
Member Author

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, operations, evidence): CLEAN

Base b2620f4b5ba52a23b809f5c5faebc646c0d04ddd, head 522df7f1030135dd619141265afd7e56de595b07. Claims checked:

  • "uv resolves min/latest from pyproject.toml": uv pip compile --resolution lowest-direct|highest gives 2.0.52 and 2.1.9, and the recipe prints them.
  • "Collection catches Decode float ARRAY elements and run the compliance suite on SQLAlchemy 2.1 #1569's import error": master before Decode float ARRAY elements and import the compliance suite on SQLAlchemy 2.1 (GH-1569) #1577 fails to collect on 2.1.9 with ImportError: DeprecatedCompoundSelectTest (checked earlier in this session), and pytest exits non-zero, which fails the recipe under set -e.
  • AWS: the job runs offline with no credentials; the targeted live run of the tests that 2.1.9 adds was approved by the maintainer and cost about 80 cases per driver. Results are in the PR body. NameDenormalizeTest is the only failure, and it is now skipped with its reason: 2 passed and 6 skipped on both drivers.
  • CI: no needs: link to the AWS jobs, so a new SQLAlchemy release that breaks the job does not stop the AWS suites of unrelated PRs. The min row uses Python 3.11, the oldest supported version; the locally verified rows use 3.15.

runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
contents: read
strategy:
fail-fast: false
matrix:
# Each series runs on the newest Python version for which its releases
# publish compiled wheels, so the versions differ: SQLAlchemy 2.0 has
# none for Python 3.15, where only its pure-Python wheel, without the
# C extensions, would install. Move a series to a newer Python version
# once its releases publish compiled wheels for it.
include:
- sqlalchemy: '2.0'

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maintainer-requested change and self-review (both perspectives): 48fd2b7b..26a9e278

The maintainer asked for the job to test the 2.0 and 2.1 series rather than the minimum and the latest release, and for 2.0 to use the newest Python version for which it publishes wheels, with a comment explaining why the Python versions differ.

  • The recipe takes a series (2.0) or a version (2.1.9). A series is resolved with uv pip compile --constraint <(echo "sqlalchemy>=2.0,<2.1") within the extras' range. The other dependencies stay locked; lowest-direct used to lower them all.
  • Wheels on PyPI: SQLAlchemy 2.0.58 publishes up to cp314 and 2.1.9 up to cp315. So the matrix is 2.0 on Python 3.14 and 2.1 on 3.15. Only the 3.15 row needs setup-python, as before.
  • The docs (testing.md, contributing.md, AGENTS.md) and the just test help describe the series. The PYTHON_VERSIONS sync comment still applies, since the matrix uses 3.14 and 3.15.
  • Compatibility: min/latest are removed from an unreleased recipe. The recipe now needs an argument, and just reports the missing parameter.

Validation:

  • just lint and just docs lint: passed.
  • With UV_PYTHON and a temporary UV_PROJECT_ENVIRONMENT, as in CI:
    • just test offline-sqla 2.0 on 3.14 (2.0.58): 734 passed; both compliance collections succeeded.
    • just test offline-sqla 2.1 on 3.15 (2.1.9): 734 passed; both compliance collections succeeded.
  • just test offline-sqla 2.1.9: 734 passed.

python-version: '3.14'
- sqlalchemy: '2.1'
python-version: '3.15'
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0
with:
python-version: ${{ matrix.python-version }}
enable-cache: true
# As in the offline job, uv's Python 3.13+ cannot compile Python.h.
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: ${{ matrix.python-version }}
- uses: taiki-e/install-action@7a79fe8c3a13344501c80d99cae481c1c9085912 # v2.81.10
with:
tool: just
- run: just test offline-sqla ${{ matrix.sqlalchemy }}

# Selects the AWS suites and Python versions. Draft and external-fork pull
# requests run none. A ready pull request runs the PyAthena suite only when
# the package, the tests, setup.cfg, the dependencies, or this workflow
Expand Down Expand Up @@ -168,7 +211,8 @@ jobs:
EVENT_NAME: ${{ github.event_name }}
REQUESTED_VERSIONS: ${{ inputs.python-versions }}
# Every supported version, oldest first; keep in sync with the
# pyproject.toml classifiers and the offline job's version.
# pyproject.toml classifiers, the offline job's version, and the
# offline-sqla job's matrix.
PYTHON_VERSIONS: '["3.11", "3.12", "3.13", "3.14", "3.15"]'
run: |
case "$EVENT_NAME" in
Expand Down
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ just lint # Python lint, format check, mypy, CloudFormation validation, and li
```bash
# ALWAYS run `just lint` first — tests will fail if lint doesn't pass
just test offline # PyAthena tests that need no AWS, with no AWS credentials or .env
just test offline-sqla 2.0 # SQLAlchemy tests that need no AWS on the latest 2.0 release (also 2.1, or a version)
just test pyathena # PyAthena tests, including AWS integration (runs lint first)
just test sqla # SQLAlchemy compliance suite
just test sqla-async # SQLAlchemy async compliance suite
Expand Down
1 change: 1 addition & 0 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Choose coverage based on the affected behavior, including synchronous and asynch
SQLAlchemy dialect changes require the relevant PyAthena dialect tests under `tests/pyathena/sqlalchemy/` as well as the SQLAlchemy compliance suite (`just test sqla`).
Changes affecting async dialects also require the relevant tests under `tests/pyathena/aio/sqlalchemy/` and `just test sqla-async`.
The PyAthena dialect tests are included in `just test pyathena`; they are not run by the two compliance-suite commands.
`just test offline-sqla 2.0` and `just test offline-sqla 2.1` run the dialect tests that need no AWS, and collect the compliance suites, on the latest release of each supported SQLAlchemy series.
Exercise the regression on the version before the fix where practical, and record the before/after result.
Documentation-only changes need documentation checks; changes limited to logic independent of AWS need appropriate tests for that logic.
`just test offline` runs the tests that need no AWS without AWS credentials; the testing guide describes when a change also needs the AWS tests.
Expand Down
12 changes: 12 additions & 0 deletions docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,17 @@ When a change affects a request to AWS, or how PyAthena reads what AWS returns,
uv run --env-file .env pytest -n 1 -m aws tests/pyathena/test_cursor.py
```

`just test offline` runs the SQLAlchemy tests on the locked SQLAlchemy.
`just test offline-sqla <series-or-version>` runs the SQLAlchemy tests that need no AWS (`tests/pyathena/sqlalchemy/` and `tests/pyathena/aio/sqlalchemy/`) on another release, in the same environment, and collects the compliance suites (`tests/sqlalchemy/`, synchronous and `--dburi async`), which imports them without contacting AWS:

```bash
just test offline-sqla 2.0 # the latest 2.0 release that the sqlalchemy extras allow
just test offline-sqla 2.1 # the latest 2.1 release
just test offline-sqla 2.1.9 # a given release
```

uv resolves a series from `pyproject.toml`, and the recipe prints the SQLAlchemy version that it runs.

### S3 null-version moves

The null-version move regression tests create three dedicated temporary buckets:
Expand Down Expand Up @@ -271,6 +282,7 @@ Retain dtype and schema checks, option contexts, and resource cleanup where appl

The Test workflow runs for pull requests that change files other than `docs/` and Markdown.
It runs the offline checks (`just lint`, and `just test offline` on the newest supported Python version) on each of them, including Drafts and external forks.
It also runs `just test offline-sqla 2.0` and `just test offline-sqla 2.1`, for each supported SQLAlchemy series, each on the newest Python version for which that series publishes compiled wheels; the AWS suites do not wait for these, and the Release workflow requires them.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent follow-up 5 (Codex, session 01a22ee2-80f3-7a31-9330-571f29f26098, 26a9e278..397f4fa2): FINDINGS, repaired in 8d309389

The reviewer confirmed that three of the four follow-up 4 findings are resolved. UV_RESOLUTION=lowest still selects 2.0.58, both rows run setup-python, and the wheel comment is accurate.

Remaining: the GitHub Actions section of the testing guide showed just test offline-sqla without its required argument. It now shows just test offline-sqla 2.0 and just test offline-sqla 2.1. just docs lint: passed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent follow-up 6 (Codex, session 01a22ef0-b1e7-7601-942e-661dc222dbd2, 397f4fa2..8d309389): CLEAN. Both CI invocations in the testing guide now pass the series argument, matching the matrix.

The AWS suites start only after the offline checks pass, and run as follows:

| Trigger | PyAthena suite | SQLAlchemy tests | Spark tests | Python versions |
Expand Down
62 changes: 49 additions & 13 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,31 +35,37 @@ lint: license-headers
license-headers:
uv run python scripts/check_license_headers.py

# Run tests: just test (pyathena|offline|sqla|sqla-async)
test target="help":
@just _test-{{ if target =~ "^-" { "help" } else { target } }}
# Run tests: just test (pyathena|offline|offline-sqla SERIES|VERSION|sqla|sqla-async)
[positional-arguments]
test target="help" *args:
@shift && just _test-{{ if target =~ "^-" { "help" } else { target } }} "$@"

_test-help:
@echo "Usage: just test <target>"
@echo ""
@echo "Targets:"
@echo " pyathena Run the PyAthena tests, including AWS integration tests (runs lint first)"
@echo " offline Run the PyAthena tests that need no AWS, with no AWS credentials"
@echo " offline-sqla SERIES|VERSION"
@echo " Run the SQLAlchemy tests that need no AWS and collect the compliance"
@echo " suites on the latest release of a series, such as 2.0, or a version"
@echo " sqla Run SQLAlchemy dialect tests"
@echo " sqla-async Run SQLAlchemy async dialect tests"

_test-pyathena: lint
uv run pytest -n 8 {{PYTEST_RERUN}} --cov pyathena --cov-report html --cov-report term tests/pyathena/

# Sync the environment first, as uv run does, with the developer's settings.
# Then unset every AWS and fsspec setting and HTTP_PROXY, HTTPS_PROXY, and
# ALL_PROXY in either case, set NO_PROXY and no_proxy to '*', and give the four
# settings that tests/__init__.py requires placeholder values. A request
# made by accident carries credentials that no account accepts, and the clients
# that read AWS_ENDPOINT_URL send it to a reserved name that does not resolve
# (RFC 6761), with AWS_MAX_ATTEMPTS=1 and POLARS_CLOUD_MAX_RETRIES=0. uv must not
# load a .env file back.
_test-offline:
# Run a command with no AWS settings, for the tests that need no AWS. Sync the
# environment first, as uv run does, with the developer's settings. Then unset
# every AWS and fsspec setting and HTTP_PROXY, HTTPS_PROXY, and ALL_PROXY in
# either case, set NO_PROXY and no_proxy to '*', and give the four settings that
# tests/__init__.py requires placeholder values. A request made by accident
# carries credentials that no account accepts, and the clients that read
# AWS_ENDPOINT_URL send it to a reserved name that does not resolve (RFC 6761),
# with AWS_MAX_ATTEMPTS=1 and POLARS_CLOUD_MAX_RETRIES=0. uv must not load a
# .env file back.
[positional-arguments]
_offline *command:
#!/usr/bin/env bash
set -euo pipefail
uv run --no-env-file true
Expand All @@ -73,7 +79,37 @@ _test-offline:
export AWS_CONFIG_FILE=/dev/null AWS_SHARED_CREDENTIALS_FILE=/dev/null BOTO_CONFIG=/dev/null
export AWS_EC2_METADATA_DISABLED=true FSSPEC_CONFIG_DIR=/dev/null
export AWS_ENDPOINT_URL=https://offline.invalid AWS_MAX_ATTEMPTS=1 POLARS_CLOUD_MAX_RETRIES=0
uv run --no-sync --no-env-file pytest -n auto -p no:rerunfailures -m "not aws" tests/pyathena/
"$@"

_test-offline:
@just _offline uv run --no-sync --no-env-file pytest -n auto -p no:rerunfailures -m "not aws" tests/pyathena/

# The SQLAlchemy tests that need no AWS, and the collection of the compliance
# suites (which imports them without contacting AWS), on another SQLAlchemy:
# a series such as 2.0 runs its latest release that the extras allow, resolved
# by uv, and any other value is a version. The packages are resolved and cached
# before _offline removes the proxy settings, and the runs inside it use that
# cache only (--offline), so the recipe needs uv's cache.
[positional-arguments]
_test-offline-sqla version:
#!/usr/bin/env bash
set -euo pipefail
if [[ "$1" =~ ^([0-9]+)\.([0-9]+)$ ]]; then
series="sqlalchemy>=$1,<${BASH_REMATCH[1]}.$((BASH_REMATCH[2] + 1))"
version=$(uv pip compile pyproject.toml --extra sqlalchemy --extra aiosqlalchemy \
--constraint <(echo "$series") --resolution highest \

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent follow-up 4 (Codex, 48fd2b7b..26a9e278): FINDINGS, repaired in 397f4fa2

  1. With UV_RESOLUTION=lowest-direct, 2.0 resolved to 2.0.52. uv pip compile now gets --resolution highest, and the same environment resolves 2.0.58.
  2. The 3.14 row skipped setup-python, which uv's Python 3.13+ needs to compile Python.h. Both rows now use it, and the PYTHON_VERSIONS sync comment no longer mentions a condition.
  3. SQLAlchemy 2.0.58 also publishes py3-none-any, so Python 3.15 would install the pure-Python wheel, not build from source. The matrix comment and the testing guide now say "compiled wheels".
  4. The testing guide now shows the required argument (just test offline-sqla <series-or-version>).

The reviewer also ran both series in isolation. Each passed 734 tests and collected both compliance suites, and the other packages matched the lock. 1.4 was rejected by the extras' bound.

Validation: just lint, just docs lint, and actionlint: passed.

--no-deps --no-header --no-annotate --quiet \
| sed -n 's/^sqlalchemy==//p')
else
version="$1"
fi
with="sqlalchemy[asyncio]==$version"
echo "SQLAlchemy $version"
uv run --no-env-file --with "$with" true
run=(uv run --offline --no-sync --no-env-file --with "$with")
just _offline "${run[@]}" pytest -n auto -p no:rerunfailures -m "not aws" tests/pyathena/sqlalchemy/ tests/pyathena/aio/sqlalchemy/
just _offline "${run[@]}" pytest -n 0 -p no:rerunfailures --collect-only -qq tests/sqlalchemy/
just _offline "${run[@]}" pytest -n 0 -p no:rerunfailures --collect-only -qq tests/sqlalchemy/ --dburi async

_test-sqla:
uv run pytest -n 8 {{PYTEST_RERUN}} --cov pyathena --cov-report html --cov-report term tests/sqlalchemy/
Expand Down
14 changes: 14 additions & 0 deletions tests/sqlalchemy/test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -1276,6 +1276,20 @@ class CompoundSelectTest(_InsertFixtureRowsOnce, _CompoundSelectTest):
pass


if hasattr(sa_suite, "NameDenormalizeTest"): # SQLAlchemy 2.1 and later

class NameDenormalizeTest(_InsertFixtureRowsOnce, sa_suite.NameDenormalizeTest):
@functools.wraps(sa_suite.NameDenormalizeTest.test_cols_driver_cols)
def test_cols_driver_cols(self, **kwargs):
# SQLAlchemy's variations also pass exclusion arguments. Athena
# returns the column names of a core select as its column list
# writes them, but the names of `SELECT *` in lowercase, including
# quoted names, which the driver SQL and textual statements read.
if not kwargs["stmt_type"].core_select:
pytest.skip("Athena returns column names in lowercase.")
super().test_cols_driver_cols(**kwargs)


if hasattr(sa_suite, "DeprecatedCompoundSelectTest"):
# SQLAlchemy 2.1 removed this test class.

Expand Down
Loading