Skip to content

[4.x] Backport #1489, #1478, #1480, #1501, #1515 and #1534 - #1553

Merged
laughingman7743 merged 26 commits into
4.xfrom
backport/4.x-1489-1534
Nov 30, 2026
Merged

laughingman7743 merged 26 commits into
4.xfrom
backport/4.x-1489-1534

Conversation

@laughingman7743

@laughingman7743 laughingman7743 commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

WHAT

The second batch of the 4.x backports 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 a git cherry-pick -x of the master commit; all of them apply without conflict.

Follows #1552 (merged); the branch was updated with 4.x after that merge, with no change to its tree.

Master PR Issue Change on 4.x
#1489 (66335a2, 4 commits) #1488 The development-workflow and self-review skills add a differential check for changes to shared behavior. No runtime change.
#1478 (e885f62, 4 commits) #1446 The SQLAlchemy dialect's default schema is the cursor's database; a schema_translate_map value of None names it.
#1480 (ae9453b, 6 commits) #1453 Filesystem helpers move to the objects they operate on, as public methods (S3Object.to_path(), S3Path.covers(), S3Core.check_block_size(), ...).
#1501 (23e2a43, 1 commit) #1486 AthenaTableMetadata.serde_properties removes only the leading serde.param. prefix.
#1515 (b470b1c, 8 commits) #1512 The AWS test session is provisioned only for the tests that use it (aws_test_schema); -m "not aws" selects the tests that need no AWS. Tests, docs/testing.md, AGENTS.md and a comment in the test-suite workflow only.
#1534 (c2c7233, 2 commits) #1509 An empty S3Path version ID is stored as None.

Release notes (from the master PRs):

  • Set the dialect's default schema to the cursor's database (GH-1446) #1478, behavior changes:
    • dialect.default_schema_name and Inspector.default_schema_name return a database name after the engine's first connection instead of None. Tools that read them, such as Alembic autogenerate with a user-registered awsathena migration implementation, now treat that database as the default schema.
    • A schema_translate_map value of None no longer raises CompileError (as StatementError); it qualifies tables with the default schema.
    • With a creator= connection that runs in a database other than the URL database, the default LOCATION of a table left without a schema names the connection's database.
    • The value is fixed per engine at the first connection. A DB-API connection returned by creator= must expose schema_name and cursor_kwargs when the engine first connects; a connection without them fails the first connect with AttributeError.
  • Move the filesystem helpers to the objects they operate on (GH-1453) #1480, behavior change: the block-size errors of S3MultipartWriter and of S3File opened for writing raise the ValueError message of S3Core.plan_multipart_copy(). The exception type and the accepted range are unchanged. S3DeleteBatch moves to pyathena.filesystem.s3_object and stays importable from pyathena.filesystem.s3_core.
  • Remove only the leading serde.param. prefix from SerDe property names (GH-1486) #1501, fix: AthenaTableMetadata.serde_properties and the reflected awsathena_serdeproperties keep a serde.param. that appears inside a SerDe property name.
  • Store an empty S3Path version ID as None (GH-1509) #1534, fix: info() of a path with an empty version ID (?versionId=) reports version_id: None instead 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-diff of each master PR's commits against this branch shows identical patches apart from the cherry picked from lines.

WHY

#1327 decided to backport the fixes merged to master after the 4.x cut 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.x merged in) has the same tree.

  • just lint and just docs lint: passed.
  • Offline 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.
  • Not run locally: the AWS integration tests and the SQLAlchemy compliance suites. They run in CI when this PR is marked Ready.

🤖 Generated with Claude Code

laughingman7743 and others added 25 commits November 30, 2026 00:35
…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)
…-1446)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit e2e6245)
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)
…H-1512)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 5ea62f3)
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:

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 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:

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:

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 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:

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:

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 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:

  1. A creator= connection without cursor_kwargs/schema_name fails 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.
  2. An S3Path pickled by v4.3.0 with version_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.
  3. docs/testing.md overstates when provisioning is avoided, since TestS3FSCursor::test_invalid_arraysize requests s3fs_cursor (testing.md:108). Rejected: that fixture requests aws_test_schema (conftest.py:404), so the test is an AWS test by the guide's definition and carries the aws mark; the statement holds.
  4. test_s3_writer.py:108 pins the exception message. A master test-style point; goes to the maintainer with the others.

Base automatically changed from backport/4.x-1481-1498-1516 to 4.x November 30, 2026 01:16
return schema or cls._cursor_option(raw_connection, "schema_name") or "default"

@override
def _get_default_schema_name(self, connection: Connection) -> str:

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.

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.

@laughingman7743
laughingman7743 marked this pull request as ready for review November 30, 2026 01:33
@laughingman7743
laughingman7743 merged commit dc7f81a into 4.x Nov 30, 2026
16 checks passed
@laughingman7743
laughingman7743 deleted the backport/4.x-1489-1534 branch November 30, 2026 02:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant