Repository navigation
[4.x] Backport #1547, #1566, #1567 and #1551 - #1578
Conversation
| from collections.abc import Mapping | ||
| from itertools import product | ||
| from typing import TYPE_CHECKING, Any, cast | ||
| from typing import TYPE_CHECKING, Any, ClassVar, cast |
There was a problem hiding this comment.
Self-review round 1 (implementation behavior): CLEAN
Scope: git diff 864621f8ed7734f145aba2c0397750f722c43fff..f81120abe6634f65597d286fde44030acec01d60 (35 commits: #1547 ×14, #1566 ×2, #1567 ×9, #1551 ×10).
Covered:
- Patch fidelity:
git patch-idequals master's for 31 of 35. 1535f6f addsClassVarto this import (its use came with this commit; the import came on master with 83837ab, Validate the integer options of SQLAlchemy CREATE TABLE (GH-1473) #1531). 7c08bd0 and 4760383 are the resolved conflicts in the PR body. f3dc4d4 differs in context only (the compiler's import block). - Every changed Python file of every commit passes
ruff check --select F821,F401,F811. That is how 1535f6f's missing import was found: lint at the head passed only because 7c08bd0's conflict side had it. - SQLAlchemy floor of
4.x(>=2.0.23): Render the time-travel hint of an aliased table before its alias #1547 usesSQLCompiler.get_render_as_alias_suffix()andformat_from_hint_text(), andvisit_alias(..., ashint=True); all exist in 2.0.23. On Python 3.12 with SQLAlchemy 2.0.23, the hint, alias, update and array tests (-k "hint or time_travel or update or alias or Array or array") give 214 passed, 1 failed:TestArrayUpdate::test_bound_indices_and_values_are_reused_without_mutation. It fails the same way on plainorigin/4.x, so it predates this PR (reported to the maintainer separately). Compile update() on SQLAlchemy 2.1 (GH-1563) #1566 keeps 2.0's_ordered_valuespath. - Move the test connection helpers to tests/pyathena/util.py and remove duplicate offline tests (GH-1513, GH-1564) #1567: the removed (30) and added (43) test IDs equal master's.
- Read a version ID query only after a key, and not as a glob (GH-1491) #1551: the differential check in the PR body.
just lint,just docs lint,just test offline: 4209 passed.
Findings: none introduced by the backport.
Limits: SQLAlchemy compliance suites and AWS tests run in CI on Ready.
There was a problem hiding this comment.
Correction to this record: the sentence on how 1535f6f's missing import was found is wrong. It was found while resolving 7c08bd0: after its typing import was resolved to the 4.x line plus NamedTuple, ruff reported F821 Undefined name ClassVar for _TIME_TRAVEL_HINTS, which 1535f6f had added. The #1547 backport was then rebuilt with ClassVar imported in 1535f6f. The per-commit ruff check of the final series passes at every commit.
| from collections.abc import Mapping | ||
| from itertools import product | ||
| from typing import TYPE_CHECKING, Any, cast | ||
| from typing import TYPE_CHECKING, Any, ClassVar, cast |
There was a problem hiding this comment.
Self-review round 2 (claims, callers, operations): CLEAN
Claims checked:
- The conflict causes:
git log -S/-Gfind 83837ab (ClassVarin compiler.py), 6f04c6c (_FormattedInt, test_compiler.py) and 1ef1f0f (thefrom sqlalchemy import (list in tests/pyathena/util.py), all master only. ✓ - "Compile update() on SQLAlchemy 2.1 (GH-1563) #1566 applies to 4.x, whose
sqlalchemy>=2.0.23also allows 2.1":pyproject.tomlon this branch. ✓ - "Read a version ID query only after a key, and not as a glob (GH-1491) #1551's handoff expected a docs conflict in 9dd4e44 that does not occur": the
expires_stringsentence is on4.xsince [4.x] Backport #1540, #1533, #1535, #1537 and #1545 #1554 (from Keep the response fields, page directory-bucket uploads, and fix S3Object copies (GH-1527) #1545). ✓ - The Read a version ID query only after a key, and not as a glob (GH-1491) #1551 numbers (1082 changed, 1056 equal to master, 26 = 24
touch/touch_notruncreturn values with a moto_version_id+ 2NOISY_GET_RECrows, 20 master-onlycopy_rec/get_rec/cp_filerows of Look up the object that cp_file() copies, and leave the bucket out of a recursive copy (GH-1510) #1538) come from the harness outputs in the PR body. - The release notes repeat the master PR bodies; Read a version ID query only after a key, and not as a glob (GH-1491) #1551's is the one its handoff gives for both lines.
Existing callers: #1551 is a behavior change (release-noted). #1547 changes rendered SQL only for hints on aliases and the cases listed. Operations: none of these change request counts outside #1551's paths.
| from collections.abc import Mapping | ||
| from itertools import product | ||
| from typing import TYPE_CHECKING, Any, cast | ||
| from typing import TYPE_CHECKING, Any, ClassVar, cast |
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 01a22b71-05c5-7cf3-a4c4-ed88f12cf29d. Static review only.
Scope: 864621f8ed7734f145aba2c0397750f722c43fff..f81120abe6634f65597d286fde44030acec01d60, a detached snapshot of the head (unchanged afterwards); the prompt named the master merges, the master-only commits behind the import additions, and the 4.x SQLAlchemy floor.
Coverage: all 35 cherry-picks ("the only difference in added or removed lines is the ClassVar import required on 4.x"); alias rendering, schema translation, ORM aliases and ordered ARRAY updates against SQLAlchemy 2.0.23, later 2.0.x and 2.1.9 ("the required compiler hooks exist at the 4.x floor"); S3 parsing, globbing, cache invalidation, copy/move pairing, aio delegation; connection=/s3_filesystem, touch(), underscore keys; the consolidated tests ("the 4.x-only tests retain their coverage and AWS fixture requirements").
FINDINGS:
4.x-specific:cp_file("s3://bucket/k?versionId=/", dst)with only the objectk?versionId=/looks upk?versionId=(the path without its trailing slash), finds the directory, and copies nothing (s3.py:3508, s3_async.py:1474). Verified with Read a version ID query only after a key, and not as a glob (GH-1491) #1551's harness (synccp_filerows: before Read a version ID query only after a key, and not as a glob (GH-1491) #1551,4.xread the path as version/ofkeyand raisedFileNotFoundError). On master, a8afdaa looks up the parsed source; it is master only (it changes whatcp_file()of a folder-marker path copies), so on4.xsuch a key is treated ascp_file()treatss3://bucket/dir/with a markerdir/: as a directory. Put to the maintainer; not changed yet.- tests/sqlalchemy/test_suite.py:462 expects SQLAlchemy 2.0's result for
~(any_(flags) == True); on 2.1 the compliance test would fail. The same on master (file identical) → Fix the defects that the 4.x backport reviews found in master (get() checks, concurrent close, docs, tests) #1565. - docs/filesystem.md:758 extends the bucket-version
ValueErrortofsspec.open_files(), whose default expansion globs?. The same text on master (master docs/filesystem.md:779) → Fix the defects that the 4.x backport reviews found in master (get() checks, concurrent close, docs, tests) #1565. - The consolidated engine test (test_base.py:1854) no longer checks that
duration_secondsandverifyreach the DB-API connection. From master's Move the test connection helpers to tests/pyathena/util.py and remove duplicate offline tests (GH-1513, GH-1564) #1567 → Fix the defects that the 4.x backport reviews found in master (get() checks, concurrent close, docs, tests) #1565. placeholder_connection()docstring: already Fix the defects that the 4.x backport reviews found in master (get() checks, concurrent close, docs, tests) #1565 item 6.6.- test_s3.py:694 and test_s3_path_pairing.py:247 match undocumented exception wording; from master's Read a version ID query only after a key, and not as a glob (GH-1491) #1551 → Fix the defects that the 4.x backport reviews found in master (get() checks, concurrent close, docs, tests) #1565.
There was a problem hiding this comment.
Repair of finding 1 (maintainer's decision: include a8afdaa): f81120a → 91c5ec1, pushed with --force-with-lease
The branch was rebuilt on #1568's current head 83e748e: git cherry-pick -x a8afdaa3 (#1538 item 1, in master order before #1547), then the 35 commits of the previous series unchanged. git diff f81120ab 91c5ec13 has the patch-id of a8afdaa, and every other commit keeps its patch-id.
Self-review of the repair, round 1 (behavior): CLEAN.
- a8afdaa applies without conflict on
4.x(Keep the response fields, page directory-bucket uploads, and fix S3Object copies (GH-1527) #1545, which it conflicted with on master, is already in4.x), and its patch equals master's. - Look up the object that cp_file() copies, and leave the bucket out of a recursive copy (GH-1510) #1538's harness (
/tmp/pyathena-1510/diffcheck.py, base run twice, identical): 30 cells change on4.x, all to master's state after Look up the object that cp_file() copies, and leave the bucket out of a recursive copy (GH-1510) #1538. Master's other 48 changed cells (Look up the object that cp_file() copies, and leave the bucket out of a recursive copy (GH-1510) #1538 item 2) already have that state in the4.xbase. - Read a version ID query only after a key, and not as a glob (GH-1491) #1551's harness rerun with master's real merge points (0255e1f^1 → 0255e1f): 1083 cases change on each line, to the same states (apart from
touch()'s 4.x return value and the noisyget_recbucket rows). The finding's case,cp_file("s3://bucket/key?versionId=/", dst), now looks up and copies the keykey?versionId=/, as on master. just lint,just docs lint,just test offline(4213 passed); per-commitruffF821/F401/F811 clean.
Round 2 (claims, callers): CLEAN. The PR body adds a8afdaa's row, its release note (taken from #1538's body: marker paths are copied, cp_file("s3://bucket/k/") with only k raises before any copy, bucket// copies the key /, list-to-list copy()/mv() copy and delete marker paths), and the new test numbers. This is a behavior change for 4.x callers that relied on cp_file() skipping a marker path; it is release-noted.
An independent follow-up of the expanded scope is requested.
There was a problem hiding this comment.
Independent follow-up of the expanded scope (relayed): Codex CLI 0.172.0, gpt-6.2-astra, effort max, read-only, session 01a22b96-cd42-7dd1-825b-d0d236446d67. Static. Scope: the first commit of 83e748ed..91c5ec13 (a8afdaa) in full, in the 4.x context, and git range-diff 864621f8..f81120ab 83e748ed..91c5ec13 (snapshot unchanged afterwards).
Coverage: the five files of the a8afdaa backport match master's hunks; "the range-diff marks all 35 later patches as equivalent, and the final path parser and copy-pairing code match 0255e1f0"; the interfaces it uses exist on 4.x; connection=, s3_filesystem, touch()'s to_dict() keep their 4.x behavior; the reported case is fixed (with only k?versionId=/, lookup and copy use that literal key).
FINDINGS (both also on master, so they are not changed in the backport; added to #1565 as items 7 and 8):
- With only
dir/child,cp_file("s3://bucket/dir/", dst)skips the directory on a cold cache but raisesFileNotFoundErrorafterfs.ls("s3://bucket/dir")(s3.py:3509, s3_cache.py:418). Verified offline withserve_s3_keys:4.xbefore a8afdaa skips in both cases; this branch, master a8afdaa and the current master raise on the warm cache. It comes with a8afdaa as on master; the fix goes to master first and is then backported. - docs/filesystem.md:776 says that a write to
bucket//such aspipe_file()raisesValueError, butcp_file(src, "s3://bucket//")copies to the key/. The same text on master (line 794).
_copy_file() of S3FileSystem and AioS3FileSystem copied the object of
the path parsed as written, but took its type and size from
_info_entry() of the path, which strips a trailing slash. The lookup
and the copy then addressed different objects:
- cp_file("s3://bucket/k/", dst) looked up "k" and sent CopyObject for
"k/", which failed with NoSuchKey.
- cp_file("s3://bucket/dir/", dst) of a folder marker "dir/" looked up
"dir", found the directory, and skipped the copy.
The size decides between CopyObject and a multipart copy, so it could
also come from the other object. _copy_file() now looks up the S3Path
that it copies, with the same lookup parameters. A folder marker is
copied, and a path whose key does not exist raises FileNotFoundError
before any copy. copy() and mv() with lists of both sources and
destinations, which pair the paths as given and copy them as
cp_file() does, now copy (and, for mv(), delete) such a marker too.
This changes what cp_file() of a marker path copies, so it is for
master only.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit a8afdaa)
…1503) visit_alias() passes a FOR ... AS OF hint of an alias of a table (through nested aliases) to the table visit, which renders it between the table and the alias, so the table keeps SQLAlchemy's quoting and schema_translate_map. The format_from_hint_text() override, which split the rendered alias text on " AS " and used the table's unquoted fullname, is removed: an unaliased table whose name renders with "AS" (BASIC, "my AS t") no longer raises, and other hints keep SQLAlchemy's default placement after the alias. Backport (4.x): this commit annotates _TIME_TRAVEL_HINTS with ClassVar in pyathena/sqlalchemy/compiler.py, whose typing import came on master with 83837ab (#1531, master only). ClassVar is added to the typing import here; nothing else changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 1535f6f)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit f041596)
An ORM aliased() entity reaches visit_alias() as an annotated copy that is equal to the hint's key but not identical to it, so filtering the hints by identity kept the hint, and SQLAlchemy rendered it again after the alias. The hint is now deleted by key. Tests cover the ORM alias, split the unaliased names into their own test, and check that a subquery's tables are rendered without the hint instead of asserting where the hint itself lands. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 254f508)
visit_alias() walks to the aliased table only after the hint matches, and visit_table() passes the table's hint alone, since the table is the only key it reads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit a5390fc)
…GH-1503) visit_alias() and visit_table() take SQLAlchemy's positional parameters through *args and read fromhints and the time-travel hint from the keyword arguments, so a compiler extension that delegates with a positional asfrom keeps working. The subquery test asserts the whole statement again, so it also fails if the hint is dropped, and the documentation example shows the SQL that its select() builds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit e9642ff)
…H-1503) visit_alias() and visit_table() declare SQLAlchemy's asfrom, ashint, iscrud and fromhints in their original positions and pass every argument to the base class in the same position, so a compiler extension that delegates with fromhints given positionally keeps the time-travel hint before the alias, and the table visit no longer receives fromhints twice. The internal hint is keyword-only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 6a07480)
visit_alias() and visit_table() forward their positional and keyword arguments unchanged and replace only fromhints, in the place where the caller passed it, when a time-travel hint is moved to the table. A compiler that follows the Athena compiler in the MRO with keyword-only hooks receives the same call as from SQLAlchemy, and an extension that delegates with positional arguments keeps the hint before the alias. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 8288b9a)
…rnal keyword (GH-1503) visit_alias() looks the alias up only when fromhints is not empty, as SQLAlchemy does, and the hint passed to the table visit is named athena_time_travel_hint so that a caller's own compile keyword is not rendered as a hint. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 36d5590)
visit_alias() passes the hint as a private str subclass, and visit_table() takes the keyword only when its value has that type, so a caller's compile keyword of the same name is passed on unchanged and never replaces or drops a table's hint. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 430595c)
The marker that carries the hint to the table visit is a NamedTuple that holds the hint as given, instead of a str subclass built from it, so a hint whose str() differs from its value, such as a str-valued Enum member, renders as its value. Backport conflict (4.x): tests/pyathena/sqlalchemy/test_compiler.py. On master, the new _VersionHint class goes before _FormattedInt, which 6f04c6c (#1531, master only) added and 4.x does not have. Resolved with this commit's own delta only: _VersionHint is added in that place, without _FormattedInt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 7c08bd0)
SQLCompiler.visit_alias() calls format_from_hint_text() with the rendered table followed by the alias suffix. For a time-travel hint on an alias of a table, the override now inserts the hint before that suffix, computed from SQLCompiler.visit_alias(ashint=True), and passes the rest to SQLAlchemy's formatting. This replaces the visit_alias() and visit_table() overrides, the hint marker and the keyword that carried it, so compiler extensions see SQLAlchemy's own calls. If the rendered text does not end with the suffix, SQLAlchemy's default placement applies. An aliased UPDATE or DELETE target gets the hint before its alias, as on master. Tests that covered the removed keyword and argument handling are replaced by a hook that appends text to every alias and a LATERAL subquery case. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit f3dc4d4)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 5a44b39)
…ing hook (GH-1503) The aliased cases use a table name that contains AS, so splitting on the first " AS " fails them, and the appending hook also renders an UPDATE target, whose text ends after the hook's comment, so removing the suffix check truncates it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 4770a18)
SQLAlchemy 2.1 removed Update._ordered_values, which the ARRAY assignment rewrite read for every UPDATE, so every update() raised AttributeError. The rewrite now reads it only where it exists; on 2.1 the values of ordered_values() are in _values, whose order _maintain_values_ordering keeps and _clone() copies. _ArrayUpdate.rewrite() gets a docstring. test_quantifier_boolean_left_operand compiled a negated quantifier comparison that SQLAlchemy 2.0 turns into a != comparison and 2.1 negates as a whole. It now compiles the != comparison itself and keeps the check of the grouped negation, so it no longer depends on the SQLAlchemy version. The docs name the two versions in their note on negation and say that SQLAlchemy 2.1 deprecates array.any() and array.all(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 34a11bc)
) SQLAlchemy 2.1 keeps only the last value of a key object passed more than once to ordered_values(), before the dialect sees the statement, so that statement assigns the last value where SQLAlchemy 2.0 raises CompileError. The docs and the docstring of _ArrayUpdate.rewrite() say so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit ef0d5a1)
…GH-1513) connect(), connect_aio() (was the aio conftest's _aio_connect()), create_test_engine() and create_async_test_engine() move out of the conftests, and the test modules import them, and ENV from tests, at the top of the file. The engine helpers are renamed because util.py already imports SQLAlchemy's create_engine(). Both engine helpers accept the same connection options, ENGINE_OPTIONS, and raise TypeError on any other key; create_async_engine() used to drop every option but unload, and create_engine() ignored unknown keys. The three Spark cursor fixtures apply one work_group rule: the Spark work group replaces a work_group of the indirect parameter, which aio_spark_cursor used to reject with TypeError. The fixtures no longer change the indirect parameter's dict. Backport conflict (4.x): the sqlalchemy import of tests/pyathena/util.py. On master, 1ef1f0f (#1508, master only) had turned the names imported from sqlalchemy into a longer parenthesized list, which 4.x does not have. Resolved with this commit's own delta only: the 4.x import line is kept, and the sqlalchemy.engine and sqlalchemy.ext.asyncio imports that the moved helpers need are added. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 4760383)
…ne engine test (GH-1513) TestAthenaDialect::test_conn_str_numeric_options checks the conversion of duration_seconds, poll_interval and result_reuse_minutes, and their types, for both dialects, as test_conn_str_boolean_options does for the boolean options. Together they check the conversion of the six options that the TestSQLAlchemyAthena::test_conn_str_* tests set. Those six tests are replaced by test_url_sets_connection_options, which sets kill_on_interrupt, result_reuse_enable, poll_interval and result_reuse_minutes in the URL of an engine and checks the public attributes of its DB API connection. verify and duration_seconds are no longer checked on the connection. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 0d02cac)
TestConnection::test_cursor_arraysize_default and test_cursor_arraysize_assignment check the default of 1000 and the rules of assigning arraysize after construction for every paged and uncapped cursor class, replacing the test_arraysize_default and test_invalid_arraysize copies of ten cursor modules. Those compared the default with an implementation constant and missed the Dict and aio cursors. TestCursor::test_cancel_initial and test_fetch_no_data keep the checks of the inherited WithFetch methods, so the Arrow, Pandas, Polars and S3FS copies of test_cancel_initial are removed, and the format-specific test_fetch_no_data tests keep only their as_*() checks. The Polars one adds as_arrow(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 7c9be8f)
…st (GH-1513) The old helper appended the options to the URL text, and SQLAlchemy decoded them when it parsed the URL. create_test_engine() puts them in the URL's query dict, which keeps them as given. The three live tests that passed URL-encoded values now pass plain ones, so the dialect gets the same values as before. test_cursor_arraysize_assignment becomes one test for the paged cursors and one for the uncapped cursors, as the constructor tests are split. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 4c318b2)
…ne template (GH-1513) aio_spark_cursor closed its cursor but not its connection, as AioSparkCursor.close() leaves the connection open; it now closes the connection too, also when the cursor cannot be created. The sync and async connection strings of tests differ only in the driver, which _engine_url() replaces, so it builds both engines' URLs from SQLALCHEMY_CONNECTION_STRING. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 4b40a1c)
…ment (GH-1513) The default and assignment tests open their cursors on offline_connection, as the per-module tests that they replace did, so a cursor that calls AWS fails them and the connection is closed. The assignment tests also reject -1, as those tests did. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 1f5510a)
…pped cursors (GH-1513) The default and assignment tests open their cursors with _opened_cursor(), which closes them, as the per-module tests that they replace did with context managers. The uncapped cursors are assigned 10000, the value of those tests, so that a cap between 1001 and 10000 fails too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit c826c3d)
…sing() (GH-1513) As coroutines, the three tests took pytest-asyncio's implicit asyncio mark. The listed cursor classes all close synchronously, so the tests stay synchronous and close their cursors with contextlib.closing(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 6a59f62)
S3Path.parse() follows the rule of GH-1481 that _strip_protocol() already applied: a query whose version ID is empty or has only slashes names no version and is part of the key, so "key?versionId=/" no longer names the version "/" of "key" in the methods that parse the path as given. A version ID query is read only after a key: "bucket?versionId=v1" and "bucket/?versionId=v1" raise ValueError instead of naming a version of the bucket path, while "bucket//?versionId=v1" stays the version v1 of the key "/". A path that ends in the form of a version ID query, also with an empty or slash-only ID, is not a glob pattern, so rm(), mv(), copy(), cat(), get() and expand_path() no longer expand its "?": rm("s3://bucket/key?versionId=") deleted "keyXversionId=" as well. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 0d74d99)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit d848f20)
…() (GH-1491) rm() rejected "bucket//?versionId=v1" as the bucket, while rm_file() and mv() address the version v1 of the key "/": a path with a version is deleted as given and never stripped to the bucket by expand_path(). S3Path.PATTERN keeps its form, and parse() rejects the bucket path with a version that it matches, instead of a second copy of the query grammar in a lookahead. The docs state that a path ending in a query that names no version is not a glob pattern also where wildcards occur before the query, and that the listed name of a key such as "?versionId=v1" at the bucket root raises when passed back. The tests check that mv() deletes what it copied and drop the duplicate and repeated cases. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit fad097c)
A path with a version names an object, so is_bucket answers it, and rm() asks it alone. The ls(), find() and chmod() checks for a version drop the key condition that only a bucket path with a version needed, which parse() no longer returns. The mv() test reads the copies with s3_copy_targets(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 30cefd5)
…ersions there (GH-1491) copy() and mv() into a directory whose name ends in a query that names no version, such as key?versionId=/, joined the source name to the string, which parsed as the version "/k" of "key". A destination named below a string path2 is now path2 parsed with the suffix added to its key, kept as the string when that string names the same path. A bucket path with a version as path2 is rejected there; a list of sources was moved below it as the key "?versionId=v1/..." and deleted. expand_path() parses the paths with a version ID, so a bucket path with a version raises as in the other methods. invalidate_cache() of the listed name of a key at the bucket root, such as bucket/?versionId=v1, evicts that name only, not the other spellings of the query. S3Path.is_bucket stays True for a path without a key. The docs name a version ID for setxattr() and state that isfile() returns False for an invalid path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 9dd4e44)
…ucket cases (GH-1491) s3_copy_pairs() parses path2 only for a destination named below it or for an S3Path source, so the contents of a directory copied to path2 itself keep the destination that copy_pairs() names, which cp_file() checks. Tests cover a string source copied into a directory at the bucket root whose joined string is no S3 path, is_bucket of a path without a key, and rm() of a bucket path with a version. The docs state the exceptions of cat_ranges() and isfile(), the glob expansion of a list in fsspec.open_files(), and the string path2 that s3_copy_pairs() needs to return S3Path destinations; the expand_path() docstrings name the ValueError of a path with a version ID. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 3f36973)
…H-1491) The docs name both glob expansions of fsspec.open_files() (a string with "*", and each path of a list with expand=True, which fsspec.open() uses when expanding) and limit the ValueError of a bucket path with a version to the methods that read it, besides invalidate_cache(), which invalidates the listed name of a key at the bucket root. The s3_copy_pairs() docstring defers the check of path2 itself only for a string source. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit d97b0fa)
…H-1491) Instead of listing the modes in which fsspec.open_files() expands a path as a glob pattern, the docs say that the compositions name the version where fsspec does not expand the path. glob() reads a bucket path with a version as a pattern, and s3_copy_pairs() does not parse the destination of a string source that is path2 itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit b0e1f28)
The qualifier about fsspec's glob expansion is removed; how fsspec's compositions read such names is recorded for the entry point work on the issue instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit f6e9e42)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 74353d2)
f81120a to
91c5ec1
Compare
| from collections.abc import Mapping | ||
| from itertools import product | ||
| from typing import TYPE_CHECKING, Any, cast | ||
| from typing import TYPE_CHECKING, Any, ClassVar, cast |
There was a problem hiding this comment.
Branch update after #1568 merged: review scope unchanged
gh pr update-branch merged 4.x (a6b5dc7, the merge of #1568) into this branch: head 91c5ec1 → 06a8fe0. The tree of a6b5dc7 equals that of 83e748e (the base of the reviewed series), and the tree of the new head equals that of 91c5ec1, so git diff a6b5dc7a..06a8fe0c is the reviewed diff.
WHAT
The sixth batch of the
4.xbackports decided in #1327 (comment): the master PRs merged after #1556, up to #1551, in master merge order, preceded by the rest of #1538. Each commit is agit cherry-pick -xof the master commit.Follows #1568 (merged); the branch was updated with
4.xafter that merge, with no change to its tree.4.xcp_file()looks up the object that it copies, as parsed:cp_file("s3://bucket/dir/", dst)copies a folder markerdir/instead of skipping it as a directory;cp_file("s3://bucket/k/", dst)with onlykraisesFileNotFoundErrorbefore any copy;cp_file("bucket//", dst)looks up the key/; the size that selects CopyObject or a multipart copy comes from the copied object.copy()/mv()with lists of sources and destinations copy (andmv()deletes) a marker path given in such a list.FOR VERSION AS OF, ...) on an aliased table is placed between the table and its alias through SQLAlchemy's hint hook; the table keeps its quoting andschema_translate_map.update()on SQLAlchemy 2.1, which4.x'ssqlalchemy>=2.0.23also allows.tests/pyathena/util.py, and duplicate offline tests are removed. Tests only.ValueError.a8afdaa (#1538 item 1), first proposed as master only, is included by the maintainer's decision in the review of this PR: without it, #1551 makes
cp_file("s3://bucket/k?versionId=/", dst)read the keyk?versionId=/but look upk?versionId=(without the trailing slash), so with only that object it found a directory and copied nothing. With a8afdaa the lookup uses the parsed source. a8afdaa applies without conflict and its patch equals master's.Conflicts and missing prerequisites (each recorded in its commit message, resolved with the commit's own delta):
_TIME_TRAVEL_HINTSwithClassVar, whose import inpyathena/sqlalchemy/compiler.pycame on master with 83837ab (Validate the integer options of SQLAlchemy CREATE TABLE (GH-1473) #1531, master only);ClassVaris added to thetypingimport.tests/pyathena/sqlalchemy/test_compiler.py: its_VersionHintclass goes before_FormattedInton master, which 6f04c6c (Validate the integer options of SQLAlchemy CREATE TABLE (GH-1473) #1531) added; it is added without_FormattedInt.tests/pyathena/util.py: master'sfrom sqlalchemy import (...)list came with 1ef1f0f (Run SQLAlchemy statements in pyformat under the global qmark (GH-1485) #1508, master only); the4.ximport line is kept and thesqlalchemy.engineandsqlalchemy.ext.asyncioimports of the moved helpers are added.The #1551 handoff (#1491) expected a docs conflict in 9dd4e44; it applies cleanly, because #1545 (backported in #1554) already added the
expires_stringsentence to thesetxattr()paragraph.Release notes (from the master PRs):
Look up the object that cp_file() copies, and leave the bucket out of a recursive copy (GH-1510) #1538 item 1 (behavior change):
cp_file()uses the source key as written, also for its lookup: a folder marker path such ass3://bucket/dir/is copied instead of skipped,cp_file("s3://bucket/k/", dst)with onlykraisesFileNotFoundErrorbefore any copy, andcp_file("bucket//", dst)copies the key/.copy()andmv()with lists of both sources and destinations copy a marker path given in such a list, andmv()deletes it.Render the time-travel hint of an aliased table before its alias #1547: a time-travel hint on an aliased table keeps the table's quoting and
schema_translate_map; an unaliased table whose rendered name containsASno longer raises; a subquery's hint is no longer applied to the tables inside it; an empty hint leaves no trailing space (SQLAlchemy's default hint rendering).Compile update() on SQLAlchemy 2.1 (GH-1563) #1566:
update()compiles on SQLAlchemy 2.1. With 2.1, an element or slice expression passed more than once toordered_values()keeps only its last value, where 2.0 raisesCompileError.Read a version ID query only after a key, and not as a glob (GH-1491) #1551 (behavior change): a bucket path with a version (
bucket?versionId=v1,bucket/?versionId=v1) raisesValueError; a?versionId=query whose ID is empty or only slashes is part of the key everywhere and is not expanded as a glob, sorm("s3://bucket/key?versionId=")no longer deleteskeyXversionId=;rm("s3://bucket//?versionId=v1")deletes that version of the key/;copy()/mv()into a directory such askey?versionId=/writeskey?versionId=/k.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 #1568.TEST
Tested commit: 91c5ec1, on #1568's head (83e748e); the current head 06a8fe0 (
4.xmerged in) has the same tree.just lintandjust docs lint: passed.ruff check --select F821,F401,F811of every changed Python file passes at every commit.just test offline: 4213 passed.4.xare the same as on master (pytest --collect-onlybefore and after, both lines).tests.pyathena.util; the4.xbase run twice, identical): 30 cells change on4.x, all of them to master's state after Look up the object that cp_file() copies, and leave the bucket out of a recursive copy (GH-1510) #1538 (base-rb→branch-rb); master's other 48 changed cells are Look up the object that cp_file() copies, and leave the bucket out of a recursive copy (GH-1510) #1538 item 2, whose state the4.xbase (with 81123d5) already has.4.xbase run twice, identical; master run on 0255e1f^1 and 0255e1f): 1083 cases change on4.xand the same 1083 on master, each to the same state, apart from the return value oftouch()(S3PutObject.to_dict()on4.x, with a moto version ID) and theget_recbucket rows that the harness lists as noisy (NOISY_GET_REC).🤖 Generated with Claude Code