Repository navigation
[4.x] Backport #1489, #1478, #1480, #1501, #1515 and #1534 - #1553
Conversation
…ow (GH-1488) A change to a rule that many callers depend on is checked by running the same input matrix through the merge base and the branch with the same fake service, before implementing and after every repair, accepting only the intended differences. self-review reruns it on the reviewed head. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 9913541)
The Validate section forbids a parallel mock framework that mirrors the implementation; the harness compares two revisions and stays untracked, and the change's regression tests still follow that section. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit a0d6252)
The trigger covers caller-visible rules shared by more than one path and refactors meant to keep them. Each case starts from the same fake-service state; an order-dependent case keeps its concurrency under a fixed schedule; the expected difference of each intended row is written down and any other difference, also within an intended row, is a defect. The harness lives in a per-task temporary directory and runs without the test suite's session hooks, and regression tests cover changed and restored behavior too. self-review also flags a missing check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 2e23abc)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit e93c2af)
AthenaDialect did not implement _get_default_schema_name(), so default_schema_name stayed None, and a statement whose schema_translate_map gives a table None failed with a CompileError (raised as StatementError) for DML and DDL alike. The default schema is now the database that unqualified statements run in, read from the engine's first connection without a query: the cursor's schema_name, which cursor_kwargs can override, or Athena's default database. Reflection without a schema already reads the same database. When the map gives a table None, its default LOCATION uses the same name that qualifies the table. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit ccd41a5)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit b35b384)
The default LOCATION of a table left without a schema came from the connection options, which name the URL database. With a creator= connection that runs in another database, CREATE TABLE created the table there but placed its data under the URL database's path. A table left without a schema now uses the dialect's default schema, like a table that schema_translate_map maps to None, and the connection options remain the fallback before the engine connects. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit cb9d776)
The helpers that read only another object's data become public methods of that object, so that AioS3FileSystem no longer reaches into private S3FileSystem helpers for them: - S3Object: directory(), root() and from_bucket() build the one zero-size directory entry; listing_prefix(), parent_directories() and to_path() replace _directory_prefix, _extract_parent_directories and _entry_path. - S3DeleteBatch moves to s3_object beside the other delete models (still importable from s3_core); S3DeleteResult.raise_for_outcomes() replaces _raise_delete_errors. - S3Path: is_glob(), target_for(), partition_by_version(), subtree_prefix and covers() replace S3PathPairing._is_glob/_target, the version split of delete_paths/_split_version_paths, and the "key itself or keys under key/" prefix. - S3MultipartUpload.request_identity() replaces S3Core._multipart_upload_request. - S3Core.check_block_size() is the one block-size range check of plan_multipart_copy, S3MultipartWriter and S3File. - S3ClientError.is_no_such_upload() and S3Core.lookup_params() replace _is_not_no_such_upload and _get_lookup_kwargs. Behavior is unchanged except that the block-size errors of S3MultipartWriter and of S3File opened for writing now have the message of plan_multipart_copy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 52122e6)
The empty key of the directory "bucket/" lists the prefix "/", and a key that ends in a slash keeps it; no offline test pinned this. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit cf39a79)
subtree_prefix and covers() describe a path without a key, not a bucket path, which may also be written with a key of slashes (bucket//). The request identity of S3MultipartUpload, now public, rejects an incomplete upload; no test pinned that. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 4615b99)
) - S3Core.lookup_params becomes authorization_params: the parameters select what authorizes the access to an object or a bucket, which the filesystem also sends with every request; why a lookup sends only these now sits at the lookup. - S3Object.to_path() states that the path never has the version ID the entry records; listing_prefix() and S3Path.subtree_prefix point at each other; directory() notes its DIRECTORY storage class for the top level of a bucket, unlike from_bucket(). - _zero_size() takes the key and the version as defaults, and the tests build bucket-level directory entries without an explicit None. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit aa92bde)
s3.py no longer uses S3StorageClass since the directory entries are built by S3Object, but it has been importable from pyathena.filesystem.s3 since the filesystem was added. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit f4d546a)
- test_listing_of_keys_with_empty_segments and test_multipart_upload_requires_identity already fail when the listing prefix or the upload identity breaks, so the tests added for them are removed. - test_info_root checks the BUCKET storage class of the root entry, which S3Object.root() now builds. - listing_prefix() reads the key as the old helper did, and _split_version_paths() strips every path before splitting them, as before, so a malformed path raises the same error. - to_path() documents the empty key and the root entry; listing_prefix() no longer says that a parsed path's trailing slashes name no key. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 6045ee6)
…GH-1486) AthenaTableMetadata.serde_properties removed every occurrence of the prefix with str.replace(), so a property whose own name contains serde.param. was returned under another key, and two parameters could collapse into one. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> (cherry picked from commit 1f979f1)
The session hooks of tests/pyathena/conftest.py uploaded the test data and created the S3 Tables namespace, the database, and the tables for every run, including --collect-only and runs of offline tests only. A session-scoped aws_test_schema fixture now does this on first use and removes the resources at the end of the session, or as soon as a setup step fails. Every fixture and test that reaches AWS depends on it, including the live filesystem fixtures and the tests that call connect() directly, and conftest.py marks the tests that depend on it `aws`, so that `-m "not aws"` selects the tests that need no AWS. The aio cursor fixtures share one helper, and isolated_aws_config moves to conftest.py for the tests that assert endpoints or schemes, which no longer read the AWS settings of the environment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 1fa0572)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit ea73006)
pytest runs a session fixture's teardown as part of the last test's teardown, where pytest-rerunfailures reruns the test and sets up again when a removal fails with an error that the recipes rerun. The removals now run in pytest_sessionfinish, as before aws_test_schema. pytest-rerunfailures also clears a failed fixture before each rerun, so a failed setup would run again for every AWS test. It is not tried again in the process: a retry would start on the resources that a failed removal left. Later tests raise a RuntimeError caused by the original error. The arrow credentials test and the s3fs profile test use isolated_aws_config instead of their own copies of it, and the Test Suite workflow comment states when a process creates its S3 Tables namespace. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit e716c22)
pytest's own pytest_sessionfinish tears down the fixtures that a stopped session left, such as empty_table, which drops its table in the schema; the removals run after it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 0e54a1d)
pytest forgets the session fixture's result when it tears the fixture down with the last test, so a rerun of that test after a failed teardown called aws_test_schema again and set up over the existing resources. The setup now runs at most once per process. pytest_sessionfinish is a hook wrapper, so the removals run after pytest's own teardown of the fixtures that a stopped session left even when that teardown fails; a trylast implementation was skipped then. The stream-retry test builds its client from a session of its own, the Glue endpoint test uses a fixed region, and the testing guide scopes its statements about selections and stopped sessions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 8fcf507)
…GH-1512) pluggy calls a wrapper registered later outside one registered earlier. When conftest.py is loaded during collection, after pytest-xdist's worker plugin, the removals ran after the worker had reported to the controller that it finished, which then shuts the worker down. As a trylast wrapper, pytest_sessionfinish is the innermost one in either order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 80d887f)
Module-level state outlived a session when pytest ran more than one session in an interpreter, and ExitStack.close() discarded the error of pytest's own fixture teardown when a removal also failed. The setup outcome and the removals live in session.stash, and pytest_sessionfinish passes the hook's exception to the removals. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 825841f)
S3Path("bucket", "k", "") printed as bucket/k and was requested as the
key, but compared unequal to S3Path("bucket", "k"), so the conflict
checks of S3PathPairing took the two for different objects. Store an
empty version ID as None, as an empty key is.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 907d1e8)
Also state on with_version_id() that an empty string gives the path without a version. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 1e3405e)
| return schema or cls._cursor_option(raw_connection, "schema_name") or "default" | ||
|
|
||
| @override | ||
| def _get_default_schema_name(self, connection: Connection) -> str: |
There was a problem hiding this comment.
Self-review round 1 (implementation behavior): CLEAN
Scope: git diff ff5e94acf739a3125ca7377169591a2cd82e410d..6b4dd57a6685b5da061e1b95557deea55489ee0d (merge base = #1552's head; 25 commits, cherry-picks of #1489, #1478, #1480, #1501, #1515, #1534).
Covered:
- Patch fidelity:
git patch-idof all 25 commits equals that of their master commits. - Move the filesystem helpers to the objects they operate on (GH-1453) #1480 moved private helpers. No code or test that exists only on
4.x(the deprecatedconnection=path andpyathena.filesystem.s3_filesystem) calls a removed name;_split_version_pathsstays and delegates toS3Path.partition_by_version(), as on master. - Provision the AWS test session only for the tests that use it (GH-1512) #1515 marks
awsonly the tests that depend onaws_test_schema. The tests that exist only on4.x(test_s3_filesystem_is_deprecated,test_connection_deprecated*,test_connection_with_client_rejected,test_connection_conflicts_rejected,test_open_parameters_named_as_request_fields) use mocked clients and pass under-m "not aws", so none of them needs the AWS session that is no longer provisioned for it. - Set the dialect's default schema to the cursor's database (GH-1446) #1478 (this method) on
4.x's floorsqlalchemy>=2.0.23: it merged on master before Run SQLAlchemy statements in pyformat under the global qmark (GH-1485) #1508 raised the floor, so it was written against the same floor. Read the DDL staging directory and catalog from the first connection (GH-1499) #1544 (master only) later changes the DDL location code that Set the dialect's default schema to the cursor's database (GH-1446) #1478 touches;4.xkeeps Set the dialect's default schema to the cursor's database (GH-1446) #1478's version, which its tests cover. - Offline
tests/pyathena -m "not aws": 3909 passed.just lint,just docs lint.
Findings: none.
Limits: the SQLAlchemy compliance suites and live AWS tests are not run locally (CI on Ready).
| return schema or cls._cursor_option(raw_connection, "schema_name") or "default" | ||
|
|
||
| @override | ||
| def _get_default_schema_name(self, connection: Connection) -> str: |
There was a problem hiding this comment.
Self-review round 2 (claims, callers, operations): FINDINGS → repaired in the PR body
Scope: ff5e94ac..6b4dd57a6685b5da061e1b95557deea55489ee0d, the PR body, and the release notes taken from the master PRs.
Claims checked:
- "The master-only PRs merged in this range are Remove the filesystem's connection argument and the deprecated s3_filesystem (GH-1386) #1497, Return the raw touch() response and settle one request parameter rule (GH-1383) #1435, Quote parameters for the engine that parses each DDL statement #1507, Run SQLAlchemy statements in pyformat under the global qmark (GH-1485) #1508": incomplete.
git log --first-parentlists Validate the integer options of SQLAlchemy CREATE TABLE (GH-1473) #1531, Render float parameters and literals without rounding or bare NaN #1530 and Read the DDL staging directory and catalog from the first connection (GH-1499) #1544 too, merged before Store an empty S3Path version ID as None (GH-1509) #1534. The PR body now lists all seven, and says that Reject get() files that other destinations lie below and keep folder markers as directories (GH-1487) #1516 of this range is carried by [4.x] Backport #1481, #1498 and #1516 #1552 (the order set by Audit the structure and implementation of the filesystem package #1327). - Set the dialect's default schema to the cursor's database (GH-1446) #1478's release notes match its PR body, including the
creator=AttributeErrorat the first connect (checked in_get_default_schema_name(), this line:_reflection_schema(raw_connection, None)readsschema_name/cursor_kwargs). - Move the filesystem helpers to the objects they operate on (GH-1453) #1480's "import paths unchanged":
from pyathena.filesystem.s3_core import S3DeleteBatchstill resolves (it is a re-export). - Provision the AWS test session only for the tests that use it (GH-1512) #1515's "
-m \"not aws\"selects the tests that need no AWS": 3909 passed with dummy credentials and an unreachable endpoint, so none of them reached AWS.
Existing callers on 4.x: supported SQLAlchemy floor 2.0.23 (#1478 was written before #1508 raised master's floor). Python floor unchanged.
CI: #1515 changes only a comment in .github/workflows/test-suite.yaml; the workflow's jobs and conditions are unchanged.
Limits: the SQLAlchemy compliance suites run in CI only (on Ready).
| return schema or cls._cursor_option(raw_connection, "schema_name") or "default" | ||
|
|
||
| @override | ||
| def _get_default_schema_name(self, connection: Connection) -> str: |
There was a problem hiding this comment.
Independent review (relayed): Codex CLI 0.172.0, model gpt-6.2-astra, reasoning effort max, codex exec -s read-only, session 01a2280d-3fb5-7fe2-804d-08647cd8d325. Static review only (no builds or tests).
Scope: ff5e94acf739a3125ca7377169591a2cd82e410d..6b4dd57a6685b5da061e1b95557deea55489ee0d, in a detached snapshot of the head (unchanged afterwards). The prompt gave the master merge SHAs, the master-only commits and the 4.x contracts to keep (connection=/s3_filesystem, touch() → S3PutObject.to_dict(), underscore keys), with no PR number, description or author conclusions.
Reviewer coverage: all 25 cherry-picks ("the same changed paths and added and removed lines as its master source"); SQLAlchemy schema discovery, reflection, DML translation and DDL LOCATION against the SQLAlchemy 2.0.23 source; filesystem helper callers and re-exports; connection=/s3_filesystem, touch(), response-model keys; AWS marking and provisioning ("no 4.x-only test that lost coverage or depends on an unprovisioned resource").
Result for the backport: no backport-specific finding. The reviewer reported 4 findings, also present on master:
- A
creator=connection withoutcursor_kwargs/schema_namefails on the first connect (base.py:403). Rejected: an intended behavior change of Set the dialect's default schema to the cursor's database (GH-1446) #1478, listed in its release notes and in this PR's. - An
S3Pathpickled by v4.3.0 withversion_id=""keeps""when unpickled, because pickle skips__post_init__(s3_path.py:83). Reproduced: the dataclass state is restored without__post_init__. Pre-existing in Store an empty S3Path version ID as None (GH-1509) #1534 on master; it goes to the maintainer as a master issue. - docs/testing.md overstates when provisioning is avoided, since
TestS3FSCursor::test_invalid_arraysizerequestss3fs_cursor(testing.md:108). Rejected: that fixture requestsaws_test_schema(conftest.py:404), so the test is an AWS test by the guide's definition and carries theawsmark; the statement holds. test_s3_writer.py:108pins the exception message. A master test-style point; goes to the maintainer with the others.
| return schema or cls._cursor_option(raw_connection, "schema_name") or "default" | ||
|
|
||
| @override | ||
| def _get_default_schema_name(self, connection: Connection) -> str: |
There was a problem hiding this comment.
Branch update after #1552 merged: review scope unchanged
gh pr update-branch merged 4.x (6adef19, the merge of #1552) into this branch: head 6b4dd57 → 6ebed11. The tree of 6adef19 equals that of ff5e94a (the base reviewed before), and the tree of the new head equals that of 6b4dd57 (git rev-parse <sha>^{tree}), so git diff 6adef19f..6ebed114 is the reviewed diff. The two self-review rounds and the independent review above apply to it unchanged.
WHAT
The second batch of the
4.xbackports decided in #1327 (comment): the backportable master PRs merged after #1498, up to #1534, in master merge order, except #1516, which #1552 already carries (#1327 set #1481 → #1498 → #1516 as the first batch). Each commit is agit cherry-pick -xof the master commit; all of them apply without conflict.Follows #1552 (merged); the branch was updated with
4.xafter that merge, with no change to its tree.4.xdevelopment-workflowandself-reviewskills add a differential check for changes to shared behavior. No runtime change.schema_translate_mapvalue ofNonenames it.S3Object.to_path(),S3Path.covers(),S3Core.check_block_size(), ...).AthenaTableMetadata.serde_propertiesremoves only the leadingserde.param.prefix.aws_test_schema);-m "not aws"selects the tests that need no AWS. Tests,docs/testing.md,AGENTS.mdand a comment in the test-suite workflow only.S3Pathversion ID is stored asNone.Release notes (from the master PRs):
dialect.default_schema_nameandInspector.default_schema_namereturn a database name after the engine's first connection instead ofNone. Tools that read them, such as Alembic autogenerate with a user-registeredawsathenamigration implementation, now treat that database as the default schema.schema_translate_mapvalue ofNoneno longer raisesCompileError(asStatementError); it qualifies tables with the default schema.creator=connection that runs in a database other than the URL database, the defaultLOCATIONof a table left without a schema names the connection's database.creator=must exposeschema_nameandcursor_kwargswhen the engine first connects; a connection without them fails the first connect withAttributeError.S3MultipartWriterand ofS3Fileopened for writing raise theValueErrormessage ofS3Core.plan_multipart_copy(). The exception type and the accepted range are unchanged.S3DeleteBatchmoves topyathena.filesystem.s3_objectand stays importable frompyathena.filesystem.s3_core.AthenaTableMetadata.serde_propertiesand the reflectedawsathena_serdepropertieskeep aserde.param.that appears inside a SerDe property name.info()of a path with an empty version ID (?versionId=) reportsversion_id: Noneinstead of""; copies and moves that conflicted on such a path now raise before any copy.Scope decisions (#1327 and the maintainer, 2026-11-30): #1478 is included, with the behavior changes above in the release notes. #1480 is a prerequisite of #1540 and #1545 (the next backport). #1489 is a prerequisite of #1515, whose first commit edits the same skill. The master-only (5.0.0) PRs merged in this range are not included: #1497 (#1386), #1435 (#1383 decisions 4-5), #1507 (#1502), #1508 (#1485), #1531 (#1473), #1530 (#1504) and #1544 (#1499).
git range-diffof each master PR's commits against this branch shows identical patches apart from thecherry picked fromlines.WHY
#1327 decided to backport the fixes merged to master after the
4.xcut in one session, in master merge order. This PR continues after #1552.TEST
Tested commit: 6b4dd57, on #1552's head; the current head 6ebed11 (
4.xmerged in) has the same tree.just lintandjust docs lint: passed.tests/pyathena -m "not aws"(the selection that Provision the AWS test session only for the tests that use it (GH-1512) #1515 adds; dummy credentials and an unreachable endpoint, so no AWS request is sent): 3909 passed.🤖 Generated with Claude Code