Skip to content

Commit 5b94dac

Browse files
feat: add FLOAT32 enum to TypeCode (#1081)
* feat(spanner): add proto descriptors for proto and enum types in create/update/get database ddl requests PiperOrigin-RevId: 601013501 Source-Link: googleapis/googleapis@81b24a5 Source-Link: googleapis/googleapis-gen@46f0446 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNDZmMDQ0NjAzNzkwNmYwZDkwNTM2NTgzNWYwMmE2NTIyNDFmM2RlMyJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * feat: add FLOAT32 enum to TypeCode PiperOrigin-RevId: 601176446 Source-Link: googleapis/googleapis@584ecd4 Source-Link: googleapis/googleapis-gen@0bdb815 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMGJkYjgxNTc3OWQwZmQ3ODI0YmFmZmYwYzkxMDQ2YTdkY2E1Y2Q1ZiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <[email protected]>
1 parent f3b23b2 commit 5b94dac

File tree

4 files changed

+69
-2
lines changed

4 files changed

+69
-2
lines changed

google/cloud/spanner_admin_database_v1/types/spanner_database_admin.py

+57
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,26 @@ class CreateDatabaseRequest(proto.Message):
355355
database_dialect (google.cloud.spanner_admin_database_v1.types.DatabaseDialect):
356356
Optional. The dialect of the Cloud Spanner
357357
Database.
358+
proto_descriptors (bytes):
359+
Optional. Proto descriptors used by CREATE/ALTER PROTO
360+
BUNDLE statements in 'extra_statements' above. Contains a
361+
protobuf-serialized
362+
`google.protobuf.FileDescriptorSet <https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/descriptor.proto>`__.
363+
To generate it,
364+
`install <https://grpc.io/docs/protoc-installation/>`__ and
365+
run ``protoc`` with --include_imports and
366+
--descriptor_set_out. For example, to generate for
367+
moon/shot/app.proto, run
368+
369+
::
370+
371+
$protoc --proto_path=/app_path --proto_path=/lib_path \
372+
--include_imports \
373+
--descriptor_set_out=descriptors.data \
374+
moon/shot/app.proto
375+
376+
For more details, see protobuffer `self
377+
description <https://developers.google.com/protocol-buffers/docs/techniques#self-description>`__.
358378
"""
359379

360380
parent: str = proto.Field(
@@ -379,6 +399,10 @@ class CreateDatabaseRequest(proto.Message):
379399
number=5,
380400
enum=common.DatabaseDialect,
381401
)
402+
proto_descriptors: bytes = proto.Field(
403+
proto.BYTES,
404+
number=6,
405+
)
382406

383407

384408
class CreateDatabaseMetadata(proto.Message):
@@ -521,6 +545,25 @@ class UpdateDatabaseDdlRequest(proto.Message):
521545
underscore. If the named operation already exists,
522546
[UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl]
523547
returns ``ALREADY_EXISTS``.
548+
proto_descriptors (bytes):
549+
Optional. Proto descriptors used by CREATE/ALTER PROTO
550+
BUNDLE statements. Contains a protobuf-serialized
551+
`google.protobuf.FileDescriptorSet <https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/descriptor.proto>`__.
552+
To generate it,
553+
`install <https://grpc.io/docs/protoc-installation/>`__ and
554+
run ``protoc`` with --include_imports and
555+
--descriptor_set_out. For example, to generate for
556+
moon/shot/app.proto, run
557+
558+
::
559+
560+
$protoc --proto_path=/app_path --proto_path=/lib_path \
561+
--include_imports \
562+
--descriptor_set_out=descriptors.data \
563+
moon/shot/app.proto
564+
565+
For more details, see protobuffer `self
566+
description <https://developers.google.com/protocol-buffers/docs/techniques#self-description>`__.
524567
"""
525568

526569
database: str = proto.Field(
@@ -535,6 +578,10 @@ class UpdateDatabaseDdlRequest(proto.Message):
535578
proto.STRING,
536579
number=3,
537580
)
581+
proto_descriptors: bytes = proto.Field(
582+
proto.BYTES,
583+
number=4,
584+
)
538585

539586

540587
class DdlStatementActionInfo(proto.Message):
@@ -682,12 +729,22 @@ class GetDatabaseDdlResponse(proto.Message):
682729
A list of formatted DDL statements defining
683730
the schema of the database specified in the
684731
request.
732+
proto_descriptors (bytes):
733+
Proto descriptors stored in the database. Contains a
734+
protobuf-serialized
735+
`google.protobuf.FileDescriptorSet <https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/descriptor.proto>`__.
736+
For more details, see protobuffer `self
737+
description <https://developers.google.com/protocol-buffers/docs/techniques#self-description>`__.
685738
"""
686739

687740
statements: MutableSequence[str] = proto.RepeatedField(
688741
proto.STRING,
689742
number=1,
690743
)
744+
proto_descriptors: bytes = proto.Field(
745+
proto.BYTES,
746+
number=2,
747+
)
691748

692749

693750
class ListDatabaseOperationsRequest(proto.Message):

google/cloud/spanner_v1/types/type.py

+4
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ class TypeCode(proto.Enum):
5050
FLOAT64 (3):
5151
Encoded as ``number``, or the strings ``"NaN"``,
5252
``"Infinity"``, or ``"-Infinity"``.
53+
FLOAT32 (15):
54+
Encoded as ``number``, or the strings ``"NaN"``,
55+
``"Infinity"``, or ``"-Infinity"``.
5356
TIMESTAMP (4):
5457
Encoded as ``string`` in RFC 3339 timestamp format. The time
5558
zone must be present, and must be ``"Z"``.
@@ -104,6 +107,7 @@ class TypeCode(proto.Enum):
104107
BOOL = 1
105108
INT64 = 2
106109
FLOAT64 = 3
110+
FLOAT32 = 15
107111
TIMESTAMP = 4
108112
DATE = 5
109113
STRING = 6

scripts/fixup_spanner_admin_database_v1_keywords.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class spanner_admin_databaseCallTransformer(cst.CSTTransformer):
4141
METHOD_TO_PARAMS: Dict[str, Tuple[str]] = {
4242
'copy_backup': ('parent', 'backup_id', 'source_backup', 'expire_time', 'encryption_config', ),
4343
'create_backup': ('parent', 'backup_id', 'backup', 'encryption_config', ),
44-
'create_database': ('parent', 'create_statement', 'extra_statements', 'encryption_config', 'database_dialect', ),
44+
'create_database': ('parent', 'create_statement', 'extra_statements', 'encryption_config', 'database_dialect', 'proto_descriptors', ),
4545
'delete_backup': ('name', ),
4646
'drop_database': ('database', ),
4747
'get_backup': ('name', ),
@@ -58,7 +58,7 @@ class spanner_admin_databaseCallTransformer(cst.CSTTransformer):
5858
'test_iam_permissions': ('resource', 'permissions', ),
5959
'update_backup': ('backup', 'update_mask', ),
6060
'update_database': ('database', 'update_mask', ),
61-
'update_database_ddl': ('database', 'statements', 'operation_id', ),
61+
'update_database_ddl': ('database', 'statements', 'operation_id', 'proto_descriptors', ),
6262
}
6363

6464
def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode:

tests/unit/gapic/spanner_admin_database_v1/test_database_admin.py

+6
Original file line numberDiff line numberDiff line change
@@ -2377,6 +2377,7 @@ def test_get_database_ddl(request_type, transport: str = "grpc"):
23772377
# Designate an appropriate return value for the call.
23782378
call.return_value = spanner_database_admin.GetDatabaseDdlResponse(
23792379
statements=["statements_value"],
2380+
proto_descriptors=b"proto_descriptors_blob",
23802381
)
23812382
response = client.get_database_ddl(request)
23822383

@@ -2388,6 +2389,7 @@ def test_get_database_ddl(request_type, transport: str = "grpc"):
23882389
# Establish that the response is the type that we expect.
23892390
assert isinstance(response, spanner_database_admin.GetDatabaseDdlResponse)
23902391
assert response.statements == ["statements_value"]
2392+
assert response.proto_descriptors == b"proto_descriptors_blob"
23912393

23922394

23932395
def test_get_database_ddl_empty_call():
@@ -2426,6 +2428,7 @@ async def test_get_database_ddl_async(
24262428
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
24272429
spanner_database_admin.GetDatabaseDdlResponse(
24282430
statements=["statements_value"],
2431+
proto_descriptors=b"proto_descriptors_blob",
24292432
)
24302433
)
24312434
response = await client.get_database_ddl(request)
@@ -2438,6 +2441,7 @@ async def test_get_database_ddl_async(
24382441
# Establish that the response is the type that we expect.
24392442
assert isinstance(response, spanner_database_admin.GetDatabaseDdlResponse)
24402443
assert response.statements == ["statements_value"]
2444+
assert response.proto_descriptors == b"proto_descriptors_blob"
24412445

24422446

24432447
@pytest.mark.asyncio
@@ -8444,6 +8448,7 @@ def test_get_database_ddl_rest(request_type):
84448448
# Designate an appropriate value for the returned response.
84458449
return_value = spanner_database_admin.GetDatabaseDdlResponse(
84468450
statements=["statements_value"],
8451+
proto_descriptors=b"proto_descriptors_blob",
84478452
)
84488453

84498454
# Wrap the value into a proper Response obj
@@ -8460,6 +8465,7 @@ def test_get_database_ddl_rest(request_type):
84608465
# Establish that the response is the type that we expect.
84618466
assert isinstance(response, spanner_database_admin.GetDatabaseDdlResponse)
84628467
assert response.statements == ["statements_value"]
8468+
assert response.proto_descriptors == b"proto_descriptors_blob"
84638469

84648470

84658471
def test_get_database_ddl_rest_required_fields(

0 commit comments

Comments
 (0)