Skip to content

Commit

Permalink
Merge branch 'main' into index-storing-columns
Browse files Browse the repository at this point in the history
  • Loading branch information
olavloite committed Nov 8, 2024
2 parents 0301abe + fd50309 commit 85148a9
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 20 deletions.
12 changes: 6 additions & 6 deletions .kokoro/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,9 @@ google-api-core==2.22.0 \
# via
# google-cloud-core
# google-cloud-storage
google-auth==2.35.0 \
--hash=sha256:25df55f327ef021de8be50bad0dfd4a916ad0de96da86cd05661c9297723ad3f \
--hash=sha256:f4c64ed4e01e8e8b646ef34c018f8bf3338df0c8e37d8b3bba40e7f574a3278a
google-auth==2.36.0 \
--hash=sha256:51a15d47028b66fd36e5c64a82d2d57480075bccc7da37cde257fc94177a61fb \
--hash=sha256:545e9618f2df0bcbb7dcbc45a546485b1212624716975a1ea5ae8149ce769ab1
# via
# gcp-releasetool
# google-api-core
Expand Down Expand Up @@ -566,9 +566,9 @@ rfc3986==2.0.0 \
--hash=sha256:50b1502b60e289cb37883f3dfd34532b8873c7de9f49bb546641ce9cbd256ebd \
--hash=sha256:97aacf9dbd4bfd829baad6e6309fa6573aaf1be3f6fa735c8ab05e46cecb261c
# via twine
rich==13.9.3 \
--hash=sha256:9836f5096eb2172c9e77df411c1b009bace4193d6a481d534fea75ebba758283 \
--hash=sha256:bc1e01b899537598cf02579d2b9f4a415104d3fc439313a7a2c165d76557a08e
rich==13.9.4 \
--hash=sha256:439594978a49a09530cff7ebc4b5c7103ef57baf48d5ea3184f21d9a2befa098 \
--hash=sha256:6049d5e6ec054bf2779ab3358186963bac2ea89175919d699e378b99738c2a90
# via twine
rsa==4.9 \
--hash=sha256:90260d9058e514786967344d0ef75fa8727eed8a7d2e43ce9f4bcf1b536174f7 \
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ run the tests the ``nox`` package commands can be used:
Running tests on Spanner emulator
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The dialect test suite can be runned on `Spanner
The dialect test suite can be run on `Spanner
emulator <https://cloud.google.com/spanner/docs/emulator>`__. Several
tests, relating to ``NULL`` values of data types, are skipped when
executed on emulator.
Expand Down
1 change: 1 addition & 0 deletions create_test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def delete_stale_test_databases():
database_pbs = instance.list_databases()
for database_pb in database_pbs:
database = Database.from_pb(database_pb, instance)
# The emulator does not return a create_time for databases.
if database.create_time is None:
continue
create_time = datetime_helpers.to_milliseconds(database_pb.create_time)
Expand Down
63 changes: 63 additions & 0 deletions drop_test_database.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# -*- coding: utf-8 -*-
#
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import configparser
import os
import re
import time

from create_test_config import set_test_config
from google.api_core import datetime_helpers
from google.api_core.exceptions import AlreadyExists, ResourceExhausted
from google.cloud.spanner_v1 import Client
from google.cloud.spanner_v1.instance import Instance
from google.cloud.spanner_v1.database import Database


USE_EMULATOR = os.getenv("SPANNER_EMULATOR_HOST") is not None

PROJECT = os.getenv(
"GOOGLE_CLOUD_PROJECT",
os.getenv("PROJECT_ID", "emulator-test-project"),
)
CLIENT = None

if USE_EMULATOR:
from google.auth.credentials import AnonymousCredentials

CLIENT = Client(project=PROJECT, credentials=AnonymousCredentials())
else:
CLIENT = Client(project=PROJECT)


def delete_test_database():
"""Delete the currently configured test database."""
config = configparser.ConfigParser()
if os.path.exists("test.cfg"):
config.read("test.cfg")
else:
config.read("setup.cfg")
db_url = config.get("db", "default")

instance_id = re.findall(r"instances(.*?)databases", db_url)
database_id = re.findall(r"databases(.*?)$", db_url)

instance = CLIENT.instance(
instance_id="".join(instance_id).replace("/", ""))
database = instance.database("".join(database_id).replace("/", ""))
database.drop()

delete_test_database()
3 changes: 2 additions & 1 deletion google/cloud/sqlalchemy_spanner/sqlalchemy_spanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -1611,8 +1611,9 @@ def visit_column_nullable(
def visit_column_type(
element: "ColumnType", compiler: "SpannerDDLCompiler", **kw
) -> str:
return "%s %s %s" % (
return "%s %s %s %s" % (
alter_table(compiler, element.table_name, element.schema),
alter_column(compiler, element.column_name),
"%s" % format_type(compiler, element.type_),
"" if element.existing_nullable else "NOT NULL",
)
2 changes: 2 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@ def system(session):

session.run("py.test", "--quiet", os.path.join("test", "system"), *session.posargs)

session.run("python", "drop_test_database.py")


@nox.session(python=DEFAULT_PYTHON_VERSION)
def unit(session):
Expand Down
24 changes: 12 additions & 12 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#
# pip-compile --generate-hashes
#
alembic==1.13.3 \
--hash=sha256:203503117415561e203aa14541740643a611f641517f0209fcae63e9fa09f1a2 \
--hash=sha256:908e905976d15235fae59c9ac42c4c5b75cfcefe3d27c0fbf7ae15a37715d80e
alembic==1.14.0 \
--hash=sha256:99bd884ca390466db5e27ffccff1d179ec5c05c965cfefc0607e69f9e411cb25 \
--hash=sha256:b00892b53b3642d0b8dbedba234dbf1924b69be83a9a769d5a624b01094e304b
# via -r requirements.in
build==1.2.2.post1 \
--hash=sha256:1d61c0887fa860c01971625baae8bdd338e517b836a2f70dd1f7aa3a6b2fc5b5 \
Expand Down Expand Up @@ -147,9 +147,9 @@ google-api-core[grpc]==2.22.0 \
# via
# google-cloud-core
# google-cloud-spanner
google-auth==2.35.0 \
--hash=sha256:25df55f327ef021de8be50bad0dfd4a916ad0de96da86cd05661c9297723ad3f \
--hash=sha256:f4c64ed4e01e8e8b646ef34c018f8bf3338df0c8e37d8b3bba40e7f574a3278a
google-auth==2.36.0 \
--hash=sha256:51a15d47028b66fd36e5c64a82d2d57480075bccc7da37cde257fc94177a61fb \
--hash=sha256:545e9618f2df0bcbb7dcbc45a546485b1212624716975a1ea5ae8149ce769ab1
# via
# google-api-core
# google-cloud-core
Expand Down Expand Up @@ -317,9 +317,9 @@ markupsafe==3.0.2 \
--hash=sha256:f8b3d067f2e40fe93e1ccdd6b2e1d16c43140e76f02fb1319a05cf2b79d99430 \
--hash=sha256:fcabf5ff6eea076f859677f5f0b6b5c1a51e70a376b0579e0eadef8db48c6b50
# via mako
opentelemetry-api==1.27.0 \
--hash=sha256:953d5871815e7c30c81b56d910c707588000fff7a3ca1c73e6531911d53065e7 \
--hash=sha256:ed673583eaa5f81b5ce5e86ef7cdaf622f88ef65f0b9aab40b843dcae5bef342
opentelemetry-api==1.28.0 \
--hash=sha256:578610bcb8aa5cdcb11169d136cc752958548fb6ccffb0969c1036b0ee9e5353 \
--hash=sha256:8457cd2c59ea1bd0988560f021656cecd254ad7ef6be4ba09dbefeca2409ce52
# via
# -r requirements.in
# opentelemetry-instrumentation
Expand All @@ -329,9 +329,9 @@ opentelemetry-instrumentation==0.48b0 \
--hash=sha256:94929685d906380743a71c3970f76b5f07476eea1834abd5dd9d17abfe23cc35 \
--hash=sha256:a69750dc4ba6a5c3eb67986a337185a25b739966d80479befe37b546fc870b44
# via -r requirements.in
opentelemetry-sdk==1.27.0 \
--hash=sha256:365f5e32f920faf0fd9e14fdfd92c086e317eaa5f860edba9cdc17a380d9197d \
--hash=sha256:d525017dea0ccce9ba4e0245100ec46ecdc043f2d7b8315d56b19aff0904fa6f
opentelemetry-sdk==1.28.0 \
--hash=sha256:41d5420b2e3fb7716ff4981b510d551eff1fc60eb5a95cf7335b31166812a893 \
--hash=sha256:4b37da81d7fad67f6683c4420288c97f4ed0d988845d5886435f428ec4b8429a
# via -r requirements.in
opentelemetry-semantic-conventions==0.48b0 \
--hash=sha256:12d74983783b6878162208be57c9effcb89dc88691c64992d70bb89dc00daa1a \
Expand Down
1 change: 1 addition & 0 deletions test/system/test_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from sqlalchemy import (
text,
Table,
Expand Down

0 comments on commit 85148a9

Please sign in to comment.