Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
5eade85
Add a differential check for changes to shared behavior to the workfl…
laughingman7743 Nov 28, 2026
dc88741
State that the differential harness is not a test suite (GH-1488)
laughingman7743 Nov 28, 2026
376c680
Tighten the differential check after review (GH-1488)
laughingman7743 Nov 28, 2026
6b9d8da
Use the same trigger for the differential check in every step (GH-1488)
laughingman7743 Nov 28, 2026
7d93599
Set the dialect's default schema to the cursor's database (GH-1446)
laughingman7743 Nov 28, 2026
b26089f
Say that the default schema comes from the first connection (GH-1446)
laughingman7743 Nov 28, 2026
d92a3d6
Locate unqualified tables in the default schema too (GH-1446)
laughingman7743 Nov 28, 2026
1b94678
Scope the location comments and name the staging directory source (GH…
laughingman7743 Nov 28, 2026
2d10764
Move the filesystem helpers to the objects they operate on (GH-1453)
laughingman7743 Nov 28, 2026
3721c69
Test the listing prefix of directory entries (GH-1453)
laughingman7743 Nov 28, 2026
e275a16
Qualify the subtree prefix docs and test the upload identity (GH-1453)
laughingman7743 Nov 28, 2026
7744a55
Name the authorization parameters and state the entry contracts (GH-1…
laughingman7743 Nov 28, 2026
0567e13
Keep S3StorageClass importable from the s3 module (GH-1453)
laughingman7743 Nov 28, 2026
5587103
Drop duplicate tests and keep the moved helpers' exact reads (GH-1453)
laughingman7743 Nov 28, 2026
1d93720
Remove only the leading serde.param. prefix from SerDe property names…
laughingman7743 Nov 29, 2026
6e01ecf
Provision the AWS test session only for the tests that use it (GH-1512)
laughingman7743 Nov 29, 2026
427dd6d
Scope the aws mark to tests/pyathena in the docs (GH-1512)
laughingman7743 Nov 29, 2026
99f1564
Remove the AWS test resources when the session finishes (GH-1512)
laughingman7743 Nov 29, 2026
b36d556
Remove the AWS test resources after the fixtures that use them (GH-1512)
laughingman7743 Nov 29, 2026
124604a
Set up the AWS test session once and always remove it (GH-1512)
laughingman7743 Nov 29, 2026
d493415
Remove the AWS test resources before an xdist worker reports finished…
laughingman7743 Nov 29, 2026
5a6f6d9
Keep the AWS test session state in the session stash (GH-1512)
laughingman7743 Nov 29, 2026
d92d961
Qualify when a removal failure reruns a test or leaves a namespace (G…
laughingman7743 Nov 29, 2026
f5c458b
Store an empty S3Path version ID as None (GH-1509)
laughingman7743 Nov 29, 2026
6b4dd57
Fold the empty version ID pairing case into the conflict test (GH-1509)
laughingman7743 Nov 29, 2026
6ebed11
Merge branch '4.x' into backport/4.x-1489-1534
laughingman7743 Nov 30, 2026
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
15 changes: 15 additions & 0 deletions .agents/skills/development-workflow/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Keep unrelated worktrees and changes intact.
## Prepare and publish

1. Establish the intended behavior and affected surfaces before editing.
For a change to, or a refactor of, a caller-visible rule shared by more than one path, build the [differential check](#check-shared-behavior-differentially) first.
Create one dedicated worktree per PR from the fetched `origin/master`, or from the agreed parent branch for a stacked PR.
2. Implement and validate the change using the applicable checks below.
Inspect the complete diff, changed paths, and deletions before committing and pushing.
Expand Down Expand Up @@ -64,6 +65,20 @@ Do not cancel someone else's run or increase retry limits merely to obtain green
After a failure, identify the failing API, error, retry layer, and run before deciding whether a retry is informative.
Markdown-only changes need no live AWS tests; inspect the actual workflow path filters when interpreting absent jobs.

## Check shared behavior differentially

A change to a caller-visible rule shared by more than one path, such as path normalization or parsing, path pairing, cache keys, request parameter selection, or a default shared by synchronous and asynchronous variants, needs a differential check; so does a refactor meant to leave such a rule unchanged.
Build it before implementing, from a matrix of the inputs that the change targets and the neighboring inputs that it must leave unchanged.
Cover the public operations that consume the rule, synchronous and asynchronous variants, and subclasses or configurations that the rule reads.
Run the same matrix through the merge base and the branch, giving each case the same initial fake-service state and an empty request log, and compare the results, exceptions, and requests of each case.
Run it twice on the merge base first.
Make an order-dependent case deterministic with a fixed schedule that keeps any concurrency the contract depends on, not by serializing the code under test, and record how.
With the agreed design, write down the expected difference of each intended row: its result, exception, and requests.
Rerun the check after the implementation and after every repair.
Every expected difference must appear; any other difference, including an extra one in an intended row, is a defect to fix or a design change to agree, not a review finding to wait for.
The harness is a temporary comparison tool, not a test suite: keep it in a per-task OS temporary directory, run it without the test suite's AWS session setup (the `aws_test_schema` fixture), which creates AWS resources, record its matrix and result in the PR, and give the matrix to reviewers.
Regression tests still follow the rules above for every behavior that the change adds, changes, or restores.

## Freeze review scope and preserve evidence

For each round, obtain the PR's actual base branch and published head with `gh pr view --json baseRefName,headRefOid`.
Expand Down
1 change: 1 addition & 0 deletions .agents/skills/self-review/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Perform these passes sequentially yourself; do not report them as independent re
| Simplicity and test quality | Can an existing helper or fixture express this more directly? Does a regression test exercise the failing path and assert observable behavior? Could it pass because the fake omits the real service behavior or because only the happy path runs? Does each added test protect a contract that no other test checks with the same kind of evidence, as [Choose what to test](../../../docs/testing.md#choose-what-to-test) requires? Does each removed test of a behavior that remains supported leave that behavior covered by a test that fails without it? |

Trace shared helpers into their actual callers rather than assuming every backend uses the same path.
For a change to, or a refactor of, a caller-visible rule shared by more than one path, confirm that a [differential check](../development-workflow/SKILL.md#check-shared-behavior-differentially) with its expected differences exists, and rerun it on the reviewed head; a missing check, a missing expected difference, or any other difference is a finding.
Check dependency behavior against the versions resolved by the repository and the supported compatibility range when relevant.
Treat potential findings as hypotheses: verify the named code and a concrete failure scenario before editing.
Apply verified defects and useful simplifications within the task's scope, and run affected checks.
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test-suite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ jobs:
AWS_ATHENA_SPARK_WORKGROUP: pyathena-spark
AWS_ATHENA_MANAGED_WORKGROUP: pyathena-managed
# Registered S3 Tables catalog (s3tablescatalog/<table-bucket>) for the S3
# Tables tests; each test session creates and deletes its own namespace.
# Tables tests; each test process that runs an AWS test creates and
# deletes its own namespace.
# The table bucket and the AWS analytics-services integration are
# provisioned out of band.
AWS_ATHENA_S3_TABLES_CATALOG: s3tablescatalog/laughingman7743-pyathena-s3-tables
Expand Down
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ uv run --env-file .env pytest -n 1 tests/pyathena/test_cursor.py -v
- Make expected values independent of the implementation under test. A library comparison is appropriate when matching that library is the contract; describe intentional differences with explicit expected values.
- Preserve test IDs, parameter coverage, marks, fixture scopes, and resource cleanup when reorganizing tests. SQLAlchemy compliance tests retain their upstream class and plugin conventions and applicable attribution.
- **Integration tests** (need AWS) use cursor/engine fixtures with real Athena queries; **unit tests** (no AWS) call functions directly with test data
- A test that reaches AWS without a cursor, engine, or filesystem fixture requests `aws_test_schema` with `@pytest.mark.usefixtures`; pytest marks every test under `tests/pyathena/` that depends on it `aws`, and `-m "not aws" tests/pyathena/` selects the tests that need no AWS

### Markdown Lint

Expand Down
6 changes: 3 additions & 3 deletions docs/api/filesystem.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ S3 Core
.. autoclass:: pyathena.filesystem.s3_core.S3Core
:members:

.. autoclass:: pyathena.filesystem.s3_core.S3DeleteBatch
:members:

.. autoclass:: pyathena.filesystem.s3_core.S3MultipartCopyPlan
:members:

Expand Down Expand Up @@ -162,6 +159,9 @@ S3 Operation Results
.. autoclass:: pyathena.filesystem.s3_object.S3DeleteObject
:members:

.. autoclass:: pyathena.filesystem.s3_object.S3DeleteBatch
:members:

.. autoclass:: pyathena.filesystem.s3_object.S3DeleteResult
:members:

Expand Down
5 changes: 3 additions & 2 deletions docs/filesystem.md
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,8 @@ fs.put_file("local-file", path)
`getxattr()` and `setxattr()`, their asynchronous counterparts, `S3File`, `S3Core` and
`S3PathPairing` accept an `S3Path`. `S3Path.of()` parses a path string and returns an
`S3Path` as it is. `S3Path("YOUR_S3_BUCKET", "")` is the bucket path, as
`S3Path("YOUR_S3_BUCKET")` is.
`S3Path("YOUR_S3_BUCKET")` is, and `S3Path("YOUR_S3_BUCKET", "a/x", "")` names the key
`a/x` without a version, as `S3Path("YOUR_S3_BUCKET", "a/x")` does.

`find()`, `walk()`, `tree()`, `glob()` and `expand_path()` list such keys by their
buckets and keys, and `rm()`, `chmod()`, `cat()`, `du()`, `copy()`, `mv()` and `get()`
Expand Down Expand Up @@ -831,7 +832,7 @@ of up to 1,000 objects per bucket. The objects that S3 could not delete are in t
does not exist is not an error.

```python
from pyathena.filesystem.s3_core import S3DeleteBatch
from pyathena.filesystem.s3_object import S3DeleteBatch

paths = [
S3Path.parse("s3://YOUR_S3_BUCKET/path/to/a"),
Expand Down
10 changes: 8 additions & 2 deletions docs/sqlalchemy.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,15 @@ async with engine.connect() as connection:
)
```

(reflection-and-identifiers)=

## Reflection and identifiers

The dialect reflects schemas, tables, views, columns, comments, and Athena table options.
Without an explicit schema, reflection reads the database that statements run in: the cursor's `schema_name` (which `cursor_kwargs` can override), or `default` when that is not set.
This database is also the dialect's default schema (`Inspector.default_schema_name`), which an engine reads from its first connection.
Later connections that run in another database do not change it.
A `schema_translate_map` value of `None` qualifies tables with this name.
Athena does not support primary key, foreign key, unique, or index constraints.
Its `CREATE TABLE` syntax does not enforce `nullable=False`, and reflected columns report `nullable=True` and `autoincrement=False`.
Iceberg strings do not preserve `CHAR` or `VARCHAR` length constraints; `CHAR` is not a supported Iceberg type.
Expand Down Expand Up @@ -210,8 +215,9 @@ location
Description: Specifies the location of the underlying data in the Amazon S3 from which the table is created.

Without this option, the location is `<base>/<schema>/<table>/`.
`<base>` is the `location` connection option, or the S3 staging directory of the statement's cursor (`s3_staging_dir`) when that option is not set.
`<schema>` is the table's schema after the connection's `schema_translate_map` execution option is applied; for a table left without one, it is the cursor's `schema_name` (which `cursor_kwargs` can override), or `default` when that is not set.
`<base>` is the `location` connection option or, when that option is not set, the S3 staging directory from the engine's connection options: `s3_staging_dir` in `cursor_kwargs` if given, otherwise the `s3_staging_dir` connection option, otherwise the `AWS_ATHENA_S3_STAGING_DIR` environment variable when the statement is compiled.
`<schema>` is the table's schema after the connection's `schema_translate_map` execution option is applied; for a table left without one, or mapped to `None`, it is the default schema described in [Reflection and identifiers](#reflection-and-identifiers).
Before the engine first connects, a table left without a schema uses the `schema_name` connection option (which `cursor_kwargs` can override), or `default` when that is not set.
Except for [Amazon S3 Tables](#amazon-s3-tables), which take no location, compiling `CREATE TABLE` raises `CompileError` when neither `location` nor an S3 staging directory is available.

value: s3://bucket/path/to/
Expand Down
19 changes: 11 additions & 8 deletions docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ SQLAlchemy tests of Amazon S3 Tables need a table bucket integrated with the AWS
AWS_ATHENA_S3_TABLES_CATALOG=s3tablescatalog/your-table-bucket
```

Each test process creates its own namespace in the table bucket, named like its schema, and deletes it with any remaining tables at the end; with pytest-xdist that is each worker, not the controller.
Each test process that runs a test using AWS creates its own namespace in the table bucket, named like its schema, and deletes it with any remaining tables at the end; with pytest-xdist that is each such worker, not the controller.
The test identity needs `s3tables:CreateNamespace`, `s3tables:DeleteNamespace`, `s3tables:ListTables`, and `s3tables:DeleteTable` on the table bucket.
A session that stops early leaves its namespace behind; `scripts/sweep_databases.py` removes such namespaces once they are more than one day old.
A process that is killed before its removals, or whose table or namespace deletion fails, can leave its namespace behind; `scripts/sweep_databases.py` removes such namespaces once they are more than one day old.
It also removes the database and namespace of a session still running after one day, if they are in the account, region, and table bucket that the sweep covers.

The S3 Tables tests live in `tests/pyathena/sqlalchemy/test_base.py` and `tests/pyathena/test_glue.py` and run under `just test pyathena`, not the SQLAlchemy compliance-suite commands.
Expand All @@ -104,9 +104,12 @@ If a change affects one of these features, configure and run its tests; a skip d

## Run tests

The test session hooks upload fixture data to S3 and create and remove Athena/Glue databases and tables.
Selecting a single test under `tests/pyathena/` still invokes the session setup, even when the test itself uses only mocks or pure Python logic.
Do not assume that `-k` or a single test path makes this suite offline.
The `aws_test_schema` session fixture uploads fixture data to S3, creates the Athena/Glue database, tables, and views, and removes them at the end of the session.
It runs only when a selected test uses AWS.
Such tests under `tests/pyathena/` carry the `aws` mark, which pytest adds from the fixtures that a test requests, so `-m aws` selects them and `-m "not aws"` leaves them out.
The SQLAlchemy compliance suites under `tests/sqlalchemy/` all use AWS and carry no mark.
A test that reaches AWS without a cursor, engine, or filesystem fixture requests `aws_test_schema` with `@pytest.mark.usefixtures`.
A selection under `tests/pyathena/` without `aws` tests creates nothing, but nothing stops its tests from using the AWS credentials in the environment.

Run the suites relevant to the change:

Expand All @@ -119,7 +122,7 @@ uv run --env-file .env just test sqla-async
Despite the recipe's "unit tests" label, `just test pyathena` includes AWS integration tests.
The recipes use eight pytest workers, so check your account's Athena concurrency quotas.
They also rerun a failed test once when its failure message is an Athena internal error or `Invalid S3 request`, and report the first attempt's traceback.
Failures in the session setup hooks are not rerun, and a direct `pytest` invocation does not rerun.
A failure of the session setup fails each test that uses AWS and is not tried again; a direct `pytest` invocation does not rerun.
Do not overlap test runs that share AWS resources or quota.
For a focused run with a single worker, for example:

Expand All @@ -133,7 +136,7 @@ A targeted run helps during development but does not replace other coverage requ

### Run self-contained tests offline

The pandas and Polars result-set modules have self-contained tests that can run without AWS access when the session hooks are excluded.
The pandas and Polars result-set modules have self-contained tests that can run without AWS access.
Reuse the `.env` file described in the AWS environment section if it is already configured.
For an offline-only setup, create a gitignored `.env` file in the repository root with these placeholder values:

Expand All @@ -155,7 +158,7 @@ uv run --env-file .env pytest --noconftest -p no:rerunfailures -q \

The four AWS configuration values are required by `tests/__init__.py`, which pytest still imports with `--noconftest`.
The offline-only `.env` example disables EC2 metadata to prevent implicit credential lookup through that service.
`--noconftest` excludes the AWS session hooks and fixtures; disabling the rerun plugin also avoids its local socket setup in restricted environments.
`--noconftest` excludes the conftest fixtures, including the AWS session setup; disabling the rerun plugin also avoids its local socket setup in restricted environments.
Use this invocation only for self-contained modules; integration tests need their normal fixtures and a real AWS environment.

### S3 null-version moves
Expand Down
Loading
Loading