Skip to content
This repository was archived by the owner on Mar 31, 2026. It is now read-only.

Commit 7589577

Browse files
authored
Merge branch 'main' into main
2 parents 9ae2278 + 686bda6 commit 7589577

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+572
-179
lines changed

.github/workflows/mock_server_tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
pull_request:
66
name: Run Spanner tests against an in-mem mock server
77
jobs:
8-
system-tests:
8+
mock-server-tests:
99
runs-on: ubuntu-latest
1010

1111
steps:

.github/workflows/presubmit.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
pull_request:
6+
name: Presubmit checks
7+
permissions:
8+
contents: read
9+
pull-requests: write
10+
jobs:
11+
lint:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
- name: Setup Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: 3.8
21+
- name: Install nox
22+
run: python -m pip install nox
23+
- name: Check formatting
24+
run: nox -s lint
25+
units:
26+
runs-on: ubuntu-latest
27+
strategy:
28+
fail-fast: false
29+
matrix:
30+
python: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
31+
32+
steps:
33+
- name: Checkout code
34+
uses: actions/checkout@v4
35+
- name: Setup Python
36+
uses: actions/setup-python@v5
37+
with:
38+
python-version: ${{matrix.python}}
39+
- name: Install nox
40+
run: python -m pip install nox
41+
- name: Run unit tests
42+
run: nox -s unit-${{matrix.python}}

.kokoro/presubmit/presubmit.cfg

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Format: //devtools/kokoro/config/proto/build.proto
22

3-
# Disable system tests.
3+
# Only run a subset of all nox sessions
44
env_vars: {
5-
key: "RUN_SYSTEM_TESTS"
6-
value: "false"
5+
key: "NOX_SESSION"
6+
value: "unit-3.8 unit-3.12 cover docs docfx"
77
}

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "3.53.0"
2+
".": "3.54.0"
33
}

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,21 @@
44

55
[1]: https://pypi.org/project/google-cloud-spanner/#history
66

7+
## [3.54.0](https://github.com/googleapis/python-spanner/compare/v3.53.0...v3.54.0) (2025-04-28)
8+
9+
10+
### Features
11+
12+
* Add interval type support ([#1340](https://github.com/googleapis/python-spanner/issues/1340)) ([6ca9b43](https://github.com/googleapis/python-spanner/commit/6ca9b43c3038eca1317c7c9b7e3543b5f1bc68ad))
13+
* Add sample for pre-split feature ([#1333](https://github.com/googleapis/python-spanner/issues/1333)) ([ca76108](https://github.com/googleapis/python-spanner/commit/ca76108809174e4f3eea38d7ac2463d9b4c73304))
14+
* Add SQL statement for begin transaction isolation level ([#1331](https://github.com/googleapis/python-spanner/issues/1331)) ([3ac0f91](https://github.com/googleapis/python-spanner/commit/3ac0f9131b38e5cfb2b574d3d73b03736b871712))
15+
* Support transaction isolation level in dbapi ([#1327](https://github.com/googleapis/python-spanner/issues/1327)) ([03400c4](https://github.com/googleapis/python-spanner/commit/03400c40f1c1cc73e51733f2a28910a8dd78e7d9))
16+
17+
18+
### Bug Fixes
19+
20+
* Improve client-side regex statement parser ([#1328](https://github.com/googleapis/python-spanner/issues/1328)) ([b3c259d](https://github.com/googleapis/python-spanner/commit/b3c259deec817812fd8e4940faacf4a927d0d69c))
21+
722
## [3.53.0](https://github.com/googleapis/python-spanner/compare/v3.52.0...v3.53.0) (2025-03-12)
823

924

google/cloud/spanner_admin_database_v1/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "3.53.0" # {x-release-please-version}
16+
__version__ = "3.54.0" # {x-release-please-version}

google/cloud/spanner_admin_instance_v1/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "3.53.0" # {x-release-please-version}
16+
__version__ = "3.54.0" # {x-release-please-version}

google/cloud/spanner_dbapi/connection.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
from google.api_core.exceptions import Aborted
1919
from google.api_core.gapic_v1.client_info import ClientInfo
20+
from google.auth.credentials import AnonymousCredentials
21+
2022
from google.cloud import spanner_v1 as spanner
2123
from google.cloud.spanner_dbapi import partition_helper
2224
from google.cloud.spanner_dbapi.batch_dml_executor import BatchMode, BatchDmlExecutor
@@ -784,11 +786,15 @@ def connect(
784786
route_to_leader_enabled=route_to_leader_enabled,
785787
)
786788
else:
789+
client_options = None
790+
if isinstance(credentials, AnonymousCredentials):
791+
client_options = kwargs.get("client_options")
787792
client = spanner.Client(
788793
project=project,
789794
credentials=credentials,
790795
client_info=client_info,
791796
route_to_leader_enabled=route_to_leader_enabled,
797+
client_options=client_options,
792798
)
793799
else:
794800
if project is not None and client.project != project:
@@ -798,7 +804,7 @@ def connect(
798804
database = None
799805
if database_id:
800806
database = instance.database(database_id, pool=pool)
801-
conn = Connection(instance, database)
807+
conn = Connection(instance, database, **kwargs)
802808
if pool is not None:
803809
conn._own_pool = False
804810

google/cloud/spanner_dbapi/transaction_helper.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def add_execute_statement_for_retry(
162162
self._last_statement_details_per_cursor[cursor] = last_statement_result_details
163163
self._statement_result_details_list.append(last_statement_result_details)
164164

165-
def retry_transaction(self):
165+
def retry_transaction(self, default_retry_delay=None):
166166
"""Retry the aborted transaction.
167167
168168
All the statements executed in the original transaction
@@ -202,7 +202,9 @@ def retry_transaction(self):
202202
raise RetryAborted(RETRY_ABORTED_ERROR, ex)
203203
return
204204
except Aborted as ex:
205-
delay = _get_retry_delay(ex.errors[0], attempt)
205+
delay = _get_retry_delay(
206+
ex.errors[0], attempt, default_retry_delay=default_retry_delay
207+
)
206208
if delay:
207209
time.sleep(delay)
208210

google/cloud/spanner_v1/_helpers.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,7 @@ def _metadata_with_prefix(prefix, **kw):
510510
def _retry_on_aborted_exception(
511511
func,
512512
deadline,
513+
default_retry_delay=None,
513514
):
514515
"""
515516
Handles retry logic for Aborted exceptions, considering the deadline.
@@ -520,7 +521,12 @@ def _retry_on_aborted_exception(
520521
attempts += 1
521522
return func()
522523
except Aborted as exc:
523-
_delay_until_retry(exc, deadline=deadline, attempts=attempts)
524+
_delay_until_retry(
525+
exc,
526+
deadline=deadline,
527+
attempts=attempts,
528+
default_retry_delay=default_retry_delay,
529+
)
524530
continue
525531

526532

@@ -603,12 +609,12 @@ def _metadata_with_span_context(metadata: List[Tuple[str, str]], **kw) -> None:
603609
Returns:
604610
None
605611
"""
606-
if HAS_OPENTELEMETRY_INSTALLED:
612+
if HAS_OPENTELEMETRY_INSTALLED and metadata is not None:
607613
metadata.append(("x-goog-spanner-end-to-end-tracing", "true"))
608614
inject(setter=OpenTelemetryContextSetter(), carrier=metadata)
609615

610616

611-
def _delay_until_retry(exc, deadline, attempts):
617+
def _delay_until_retry(exc, deadline, attempts, default_retry_delay=None):
612618
"""Helper for :meth:`Session.run_in_transaction`.
613619
614620
Detect retryable abort, and impose server-supplied delay.
@@ -628,15 +634,15 @@ def _delay_until_retry(exc, deadline, attempts):
628634
if now >= deadline:
629635
raise
630636

631-
delay = _get_retry_delay(cause, attempts)
637+
delay = _get_retry_delay(cause, attempts, default_retry_delay=default_retry_delay)
632638
if delay is not None:
633639
if now + delay > deadline:
634640
raise
635641

636642
time.sleep(delay)
637643

638644

639-
def _get_retry_delay(cause, attempts):
645+
def _get_retry_delay(cause, attempts, default_retry_delay=None):
640646
"""Helper for :func:`_delay_until_retry`.
641647
642648
:type exc: :class:`grpc.Call`
@@ -658,6 +664,8 @@ def _get_retry_delay(cause, attempts):
658664
retry_info.ParseFromString(retry_info_pb)
659665
nanos = retry_info.retry_delay.nanos
660666
return retry_info.retry_delay.seconds + nanos / 1.0e9
667+
if default_retry_delay is not None:
668+
return default_retry_delay
661669

662670
return 2**attempts + random.random()
663671

@@ -699,6 +707,10 @@ def __radd__(self, n):
699707
"""
700708
return self.__add__(n)
701709

710+
def reset(self):
711+
with self.__lock:
712+
self.__value = 0
713+
702714

703715
def _metadata_with_request_id(*args, **kwargs):
704716
return with_request_id(*args, **kwargs)

0 commit comments

Comments
 (0)