google-cloud-spanner 3.55.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- google/cloud/spanner.py +47 -0
- google/cloud/spanner_admin_database_v1/__init__.py +146 -0
- google/cloud/spanner_admin_database_v1/gapic_metadata.json +418 -0
- google/cloud/spanner_admin_database_v1/gapic_version.py +16 -0
- google/cloud/spanner_admin_database_v1/py.typed +2 -0
- google/cloud/spanner_admin_database_v1/services/__init__.py +15 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/__init__.py +22 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/async_client.py +4097 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/client.py +4602 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/pagers.py +989 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/transports/__init__.py +38 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/transports/base.py +820 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc.py +1303 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc_asyncio.py +1688 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/transports/rest.py +6512 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/transports/rest_base.py +1650 -0
- google/cloud/spanner_admin_database_v1/types/__init__.py +144 -0
- google/cloud/spanner_admin_database_v1/types/backup.py +1106 -0
- google/cloud/spanner_admin_database_v1/types/backup_schedule.py +369 -0
- google/cloud/spanner_admin_database_v1/types/common.py +180 -0
- google/cloud/spanner_admin_database_v1/types/spanner_database_admin.py +1303 -0
- google/cloud/spanner_admin_instance_v1/__init__.py +110 -0
- google/cloud/spanner_admin_instance_v1/gapic_metadata.json +343 -0
- google/cloud/spanner_admin_instance_v1/gapic_version.py +16 -0
- google/cloud/spanner_admin_instance_v1/py.typed +2 -0
- google/cloud/spanner_admin_instance_v1/services/__init__.py +15 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/__init__.py +22 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/async_client.py +3466 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/client.py +3881 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/pagers.py +856 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/__init__.py +38 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/base.py +545 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc.py +1347 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc_asyncio.py +1539 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/rest.py +4834 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/rest_base.py +1198 -0
- google/cloud/spanner_admin_instance_v1/types/__init__.py +104 -0
- google/cloud/spanner_admin_instance_v1/types/common.py +99 -0
- google/cloud/spanner_admin_instance_v1/types/spanner_instance_admin.py +2375 -0
- google/cloud/spanner_dbapi/__init__.py +93 -0
- google/cloud/spanner_dbapi/_helpers.py +113 -0
- google/cloud/spanner_dbapi/batch_dml_executor.py +135 -0
- google/cloud/spanner_dbapi/checksum.py +80 -0
- google/cloud/spanner_dbapi/client_side_statement_executor.py +140 -0
- google/cloud/spanner_dbapi/client_side_statement_parser.py +106 -0
- google/cloud/spanner_dbapi/connection.py +818 -0
- google/cloud/spanner_dbapi/cursor.py +609 -0
- google/cloud/spanner_dbapi/exceptions.py +172 -0
- google/cloud/spanner_dbapi/parse_utils.py +392 -0
- google/cloud/spanner_dbapi/parsed_statement.py +63 -0
- google/cloud/spanner_dbapi/parser.py +258 -0
- google/cloud/spanner_dbapi/partition_helper.py +41 -0
- google/cloud/spanner_dbapi/transaction_helper.py +294 -0
- google/cloud/spanner_dbapi/types.py +106 -0
- google/cloud/spanner_dbapi/utils.py +147 -0
- google/cloud/spanner_dbapi/version.py +20 -0
- google/cloud/spanner_v1/__init__.py +154 -0
- google/cloud/spanner_v1/_helpers.py +751 -0
- google/cloud/spanner_v1/_opentelemetry_tracing.py +165 -0
- google/cloud/spanner_v1/backup.py +397 -0
- google/cloud/spanner_v1/batch.py +433 -0
- google/cloud/spanner_v1/client.py +538 -0
- google/cloud/spanner_v1/data_types.py +350 -0
- google/cloud/spanner_v1/database.py +1968 -0
- google/cloud/spanner_v1/database_sessions_manager.py +249 -0
- google/cloud/spanner_v1/gapic_metadata.json +268 -0
- google/cloud/spanner_v1/gapic_version.py +16 -0
- google/cloud/spanner_v1/instance.py +735 -0
- google/cloud/spanner_v1/keyset.py +193 -0
- google/cloud/spanner_v1/merged_result_set.py +146 -0
- google/cloud/spanner_v1/metrics/constants.py +71 -0
- google/cloud/spanner_v1/metrics/metrics_capture.py +75 -0
- google/cloud/spanner_v1/metrics/metrics_exporter.py +384 -0
- google/cloud/spanner_v1/metrics/metrics_interceptor.py +156 -0
- google/cloud/spanner_v1/metrics/metrics_tracer.py +588 -0
- google/cloud/spanner_v1/metrics/metrics_tracer_factory.py +328 -0
- google/cloud/spanner_v1/metrics/spanner_metrics_tracer_factory.py +172 -0
- google/cloud/spanner_v1/param_types.py +110 -0
- google/cloud/spanner_v1/pool.py +813 -0
- google/cloud/spanner_v1/py.typed +2 -0
- google/cloud/spanner_v1/request_id_header.py +64 -0
- google/cloud/spanner_v1/services/__init__.py +15 -0
- google/cloud/spanner_v1/services/spanner/__init__.py +22 -0
- google/cloud/spanner_v1/services/spanner/async_client.py +2205 -0
- google/cloud/spanner_v1/services/spanner/client.py +2624 -0
- google/cloud/spanner_v1/services/spanner/pagers.py +196 -0
- google/cloud/spanner_v1/services/spanner/transports/__init__.py +38 -0
- google/cloud/spanner_v1/services/spanner/transports/base.py +520 -0
- google/cloud/spanner_v1/services/spanner/transports/grpc.py +911 -0
- google/cloud/spanner_v1/services/spanner/transports/grpc_asyncio.py +1144 -0
- google/cloud/spanner_v1/services/spanner/transports/rest.py +3468 -0
- google/cloud/spanner_v1/services/spanner/transports/rest_base.py +981 -0
- google/cloud/spanner_v1/session.py +631 -0
- google/cloud/spanner_v1/session_options.py +133 -0
- google/cloud/spanner_v1/snapshot.py +1057 -0
- google/cloud/spanner_v1/streamed.py +402 -0
- google/cloud/spanner_v1/table.py +181 -0
- google/cloud/spanner_v1/testing/__init__.py +0 -0
- google/cloud/spanner_v1/testing/database_test.py +121 -0
- google/cloud/spanner_v1/testing/interceptors.py +118 -0
- google/cloud/spanner_v1/testing/mock_database_admin.py +38 -0
- google/cloud/spanner_v1/testing/mock_spanner.py +261 -0
- google/cloud/spanner_v1/testing/spanner_database_admin_pb2_grpc.py +1267 -0
- google/cloud/spanner_v1/testing/spanner_pb2_grpc.py +882 -0
- google/cloud/spanner_v1/transaction.py +747 -0
- google/cloud/spanner_v1/types/__init__.py +118 -0
- google/cloud/spanner_v1/types/commit_response.py +94 -0
- google/cloud/spanner_v1/types/keys.py +248 -0
- google/cloud/spanner_v1/types/mutation.py +201 -0
- google/cloud/spanner_v1/types/query_plan.py +220 -0
- google/cloud/spanner_v1/types/result_set.py +379 -0
- google/cloud/spanner_v1/types/spanner.py +1815 -0
- google/cloud/spanner_v1/types/transaction.py +818 -0
- google/cloud/spanner_v1/types/type.py +288 -0
- google_cloud_spanner-3.55.0.dist-info/LICENSE +202 -0
- google_cloud_spanner-3.55.0.dist-info/METADATA +318 -0
- google_cloud_spanner-3.55.0.dist-info/RECORD +119 -0
- google_cloud_spanner-3.55.0.dist-info/WHEEL +5 -0
- google_cloud_spanner-3.55.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Copyright 2025 Google LLC
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
#
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
from typing import MutableMapping, MutableSequence
|
|
19
|
+
|
|
20
|
+
import proto # type: ignore
|
|
21
|
+
|
|
22
|
+
from google.protobuf import struct_pb2 # type: ignore
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
__protobuf__ = proto.module(
|
|
26
|
+
package="google.spanner.v1",
|
|
27
|
+
manifest={
|
|
28
|
+
"PlanNode",
|
|
29
|
+
"QueryPlan",
|
|
30
|
+
},
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class PlanNode(proto.Message):
|
|
35
|
+
r"""Node information for nodes appearing in a
|
|
36
|
+
[QueryPlan.plan_nodes][google.spanner.v1.QueryPlan.plan_nodes].
|
|
37
|
+
|
|
38
|
+
Attributes:
|
|
39
|
+
index (int):
|
|
40
|
+
The ``PlanNode``'s index in [node
|
|
41
|
+
list][google.spanner.v1.QueryPlan.plan_nodes].
|
|
42
|
+
kind (google.cloud.spanner_v1.types.PlanNode.Kind):
|
|
43
|
+
Used to determine the type of node. May be needed for
|
|
44
|
+
visualizing different kinds of nodes differently. For
|
|
45
|
+
example, If the node is a
|
|
46
|
+
[SCALAR][google.spanner.v1.PlanNode.Kind.SCALAR] node, it
|
|
47
|
+
will have a condensed representation which can be used to
|
|
48
|
+
directly embed a description of the node in its parent.
|
|
49
|
+
display_name (str):
|
|
50
|
+
The display name for the node.
|
|
51
|
+
child_links (MutableSequence[google.cloud.spanner_v1.types.PlanNode.ChildLink]):
|
|
52
|
+
List of child node ``index``\ es and their relationship to
|
|
53
|
+
this parent.
|
|
54
|
+
short_representation (google.cloud.spanner_v1.types.PlanNode.ShortRepresentation):
|
|
55
|
+
Condensed representation for
|
|
56
|
+
[SCALAR][google.spanner.v1.PlanNode.Kind.SCALAR] nodes.
|
|
57
|
+
metadata (google.protobuf.struct_pb2.Struct):
|
|
58
|
+
Attributes relevant to the node contained in a group of
|
|
59
|
+
key-value pairs. For example, a Parameter Reference node
|
|
60
|
+
could have the following information in its metadata:
|
|
61
|
+
|
|
62
|
+
::
|
|
63
|
+
|
|
64
|
+
{
|
|
65
|
+
"parameter_reference": "param1",
|
|
66
|
+
"parameter_type": "array"
|
|
67
|
+
}
|
|
68
|
+
execution_stats (google.protobuf.struct_pb2.Struct):
|
|
69
|
+
The execution statistics associated with the
|
|
70
|
+
node, contained in a group of key-value pairs.
|
|
71
|
+
Only present if the plan was returned as a
|
|
72
|
+
result of a profile query. For example, number
|
|
73
|
+
of executions, number of rows/time per execution
|
|
74
|
+
etc.
|
|
75
|
+
"""
|
|
76
|
+
|
|
77
|
+
class Kind(proto.Enum):
|
|
78
|
+
r"""The kind of [PlanNode][google.spanner.v1.PlanNode]. Distinguishes
|
|
79
|
+
between the two different kinds of nodes that can appear in a query
|
|
80
|
+
plan.
|
|
81
|
+
|
|
82
|
+
Values:
|
|
83
|
+
KIND_UNSPECIFIED (0):
|
|
84
|
+
Not specified.
|
|
85
|
+
RELATIONAL (1):
|
|
86
|
+
Denotes a Relational operator node in the expression tree.
|
|
87
|
+
Relational operators represent iterative processing of rows
|
|
88
|
+
during query execution. For example, a ``TableScan``
|
|
89
|
+
operation that reads rows from a table.
|
|
90
|
+
SCALAR (2):
|
|
91
|
+
Denotes a Scalar node in the expression tree.
|
|
92
|
+
Scalar nodes represent non-iterable entities in
|
|
93
|
+
the query plan. For example, constants or
|
|
94
|
+
arithmetic operators appearing inside predicate
|
|
95
|
+
expressions or references to column names.
|
|
96
|
+
"""
|
|
97
|
+
KIND_UNSPECIFIED = 0
|
|
98
|
+
RELATIONAL = 1
|
|
99
|
+
SCALAR = 2
|
|
100
|
+
|
|
101
|
+
class ChildLink(proto.Message):
|
|
102
|
+
r"""Metadata associated with a parent-child relationship appearing in a
|
|
103
|
+
[PlanNode][google.spanner.v1.PlanNode].
|
|
104
|
+
|
|
105
|
+
Attributes:
|
|
106
|
+
child_index (int):
|
|
107
|
+
The node to which the link points.
|
|
108
|
+
type_ (str):
|
|
109
|
+
The type of the link. For example, in Hash
|
|
110
|
+
Joins this could be used to distinguish between
|
|
111
|
+
the build child and the probe child, or in the
|
|
112
|
+
case of the child being an output variable, to
|
|
113
|
+
represent the tag associated with the output
|
|
114
|
+
variable.
|
|
115
|
+
variable (str):
|
|
116
|
+
Only present if the child node is
|
|
117
|
+
[SCALAR][google.spanner.v1.PlanNode.Kind.SCALAR] and
|
|
118
|
+
corresponds to an output variable of the parent node. The
|
|
119
|
+
field carries the name of the output variable. For example,
|
|
120
|
+
a ``TableScan`` operator that reads rows from a table will
|
|
121
|
+
have child links to the ``SCALAR`` nodes representing the
|
|
122
|
+
output variables created for each column that is read by the
|
|
123
|
+
operator. The corresponding ``variable`` fields will be set
|
|
124
|
+
to the variable names assigned to the columns.
|
|
125
|
+
"""
|
|
126
|
+
|
|
127
|
+
child_index: int = proto.Field(
|
|
128
|
+
proto.INT32,
|
|
129
|
+
number=1,
|
|
130
|
+
)
|
|
131
|
+
type_: str = proto.Field(
|
|
132
|
+
proto.STRING,
|
|
133
|
+
number=2,
|
|
134
|
+
)
|
|
135
|
+
variable: str = proto.Field(
|
|
136
|
+
proto.STRING,
|
|
137
|
+
number=3,
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
class ShortRepresentation(proto.Message):
|
|
141
|
+
r"""Condensed representation of a node and its subtree. Only present for
|
|
142
|
+
``SCALAR`` [PlanNode(s)][google.spanner.v1.PlanNode].
|
|
143
|
+
|
|
144
|
+
Attributes:
|
|
145
|
+
description (str):
|
|
146
|
+
A string representation of the expression
|
|
147
|
+
subtree rooted at this node.
|
|
148
|
+
subqueries (MutableMapping[str, int]):
|
|
149
|
+
A mapping of (subquery variable name) -> (subquery node id)
|
|
150
|
+
for cases where the ``description`` string of this node
|
|
151
|
+
references a ``SCALAR`` subquery contained in the expression
|
|
152
|
+
subtree rooted at this node. The referenced ``SCALAR``
|
|
153
|
+
subquery may not necessarily be a direct child of this node.
|
|
154
|
+
"""
|
|
155
|
+
|
|
156
|
+
description: str = proto.Field(
|
|
157
|
+
proto.STRING,
|
|
158
|
+
number=1,
|
|
159
|
+
)
|
|
160
|
+
subqueries: MutableMapping[str, int] = proto.MapField(
|
|
161
|
+
proto.STRING,
|
|
162
|
+
proto.INT32,
|
|
163
|
+
number=2,
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
index: int = proto.Field(
|
|
167
|
+
proto.INT32,
|
|
168
|
+
number=1,
|
|
169
|
+
)
|
|
170
|
+
kind: Kind = proto.Field(
|
|
171
|
+
proto.ENUM,
|
|
172
|
+
number=2,
|
|
173
|
+
enum=Kind,
|
|
174
|
+
)
|
|
175
|
+
display_name: str = proto.Field(
|
|
176
|
+
proto.STRING,
|
|
177
|
+
number=3,
|
|
178
|
+
)
|
|
179
|
+
child_links: MutableSequence[ChildLink] = proto.RepeatedField(
|
|
180
|
+
proto.MESSAGE,
|
|
181
|
+
number=4,
|
|
182
|
+
message=ChildLink,
|
|
183
|
+
)
|
|
184
|
+
short_representation: ShortRepresentation = proto.Field(
|
|
185
|
+
proto.MESSAGE,
|
|
186
|
+
number=5,
|
|
187
|
+
message=ShortRepresentation,
|
|
188
|
+
)
|
|
189
|
+
metadata: struct_pb2.Struct = proto.Field(
|
|
190
|
+
proto.MESSAGE,
|
|
191
|
+
number=6,
|
|
192
|
+
message=struct_pb2.Struct,
|
|
193
|
+
)
|
|
194
|
+
execution_stats: struct_pb2.Struct = proto.Field(
|
|
195
|
+
proto.MESSAGE,
|
|
196
|
+
number=7,
|
|
197
|
+
message=struct_pb2.Struct,
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
class QueryPlan(proto.Message):
|
|
202
|
+
r"""Contains an ordered list of nodes appearing in the query
|
|
203
|
+
plan.
|
|
204
|
+
|
|
205
|
+
Attributes:
|
|
206
|
+
plan_nodes (MutableSequence[google.cloud.spanner_v1.types.PlanNode]):
|
|
207
|
+
The nodes in the query plan. Plan nodes are returned in
|
|
208
|
+
pre-order starting with the plan root. Each
|
|
209
|
+
[PlanNode][google.spanner.v1.PlanNode]'s ``id`` corresponds
|
|
210
|
+
to its index in ``plan_nodes``.
|
|
211
|
+
"""
|
|
212
|
+
|
|
213
|
+
plan_nodes: MutableSequence["PlanNode"] = proto.RepeatedField(
|
|
214
|
+
proto.MESSAGE,
|
|
215
|
+
number=1,
|
|
216
|
+
message="PlanNode",
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
__all__ = tuple(sorted(__protobuf__.manifest))
|
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Copyright 2025 Google LLC
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
#
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
from typing import MutableMapping, MutableSequence
|
|
19
|
+
|
|
20
|
+
import proto # type: ignore
|
|
21
|
+
|
|
22
|
+
from google.cloud.spanner_v1.types import query_plan as gs_query_plan
|
|
23
|
+
from google.cloud.spanner_v1.types import transaction as gs_transaction
|
|
24
|
+
from google.cloud.spanner_v1.types import type as gs_type
|
|
25
|
+
from google.protobuf import struct_pb2 # type: ignore
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
__protobuf__ = proto.module(
|
|
29
|
+
package="google.spanner.v1",
|
|
30
|
+
manifest={
|
|
31
|
+
"ResultSet",
|
|
32
|
+
"PartialResultSet",
|
|
33
|
+
"ResultSetMetadata",
|
|
34
|
+
"ResultSetStats",
|
|
35
|
+
},
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class ResultSet(proto.Message):
|
|
40
|
+
r"""Results from [Read][google.spanner.v1.Spanner.Read] or
|
|
41
|
+
[ExecuteSql][google.spanner.v1.Spanner.ExecuteSql].
|
|
42
|
+
|
|
43
|
+
Attributes:
|
|
44
|
+
metadata (google.cloud.spanner_v1.types.ResultSetMetadata):
|
|
45
|
+
Metadata about the result set, such as row
|
|
46
|
+
type information.
|
|
47
|
+
rows (MutableSequence[google.protobuf.struct_pb2.ListValue]):
|
|
48
|
+
Each element in ``rows`` is a row whose format is defined by
|
|
49
|
+
[metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type].
|
|
50
|
+
The ith element in each row matches the ith field in
|
|
51
|
+
[metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type].
|
|
52
|
+
Elements are encoded based on type as described
|
|
53
|
+
[here][google.spanner.v1.TypeCode].
|
|
54
|
+
stats (google.cloud.spanner_v1.types.ResultSetStats):
|
|
55
|
+
Query plan and execution statistics for the SQL statement
|
|
56
|
+
that produced this result set. These can be requested by
|
|
57
|
+
setting
|
|
58
|
+
[ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
|
|
59
|
+
DML statements always produce stats containing the number of
|
|
60
|
+
rows modified, unless executed using the
|
|
61
|
+
[ExecuteSqlRequest.QueryMode.PLAN][google.spanner.v1.ExecuteSqlRequest.QueryMode.PLAN]
|
|
62
|
+
[ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
|
|
63
|
+
Other fields might or might not be populated, based on the
|
|
64
|
+
[ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
|
|
65
|
+
precommit_token (google.cloud.spanner_v1.types.MultiplexedSessionPrecommitToken):
|
|
66
|
+
Optional. A precommit token is included if the read-write
|
|
67
|
+
transaction is on a multiplexed session. Pass the precommit
|
|
68
|
+
token with the highest sequence number from this transaction
|
|
69
|
+
attempt to the [Commit][google.spanner.v1.Spanner.Commit]
|
|
70
|
+
request for this transaction.
|
|
71
|
+
"""
|
|
72
|
+
|
|
73
|
+
metadata: "ResultSetMetadata" = proto.Field(
|
|
74
|
+
proto.MESSAGE,
|
|
75
|
+
number=1,
|
|
76
|
+
message="ResultSetMetadata",
|
|
77
|
+
)
|
|
78
|
+
rows: MutableSequence[struct_pb2.ListValue] = proto.RepeatedField(
|
|
79
|
+
proto.MESSAGE,
|
|
80
|
+
number=2,
|
|
81
|
+
message=struct_pb2.ListValue,
|
|
82
|
+
)
|
|
83
|
+
stats: "ResultSetStats" = proto.Field(
|
|
84
|
+
proto.MESSAGE,
|
|
85
|
+
number=3,
|
|
86
|
+
message="ResultSetStats",
|
|
87
|
+
)
|
|
88
|
+
precommit_token: gs_transaction.MultiplexedSessionPrecommitToken = proto.Field(
|
|
89
|
+
proto.MESSAGE,
|
|
90
|
+
number=5,
|
|
91
|
+
message=gs_transaction.MultiplexedSessionPrecommitToken,
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
class PartialResultSet(proto.Message):
|
|
96
|
+
r"""Partial results from a streaming read or SQL query. Streaming
|
|
97
|
+
reads and SQL queries better tolerate large result sets, large
|
|
98
|
+
rows, and large values, but are a little trickier to consume.
|
|
99
|
+
|
|
100
|
+
Attributes:
|
|
101
|
+
metadata (google.cloud.spanner_v1.types.ResultSetMetadata):
|
|
102
|
+
Metadata about the result set, such as row
|
|
103
|
+
type information. Only present in the first
|
|
104
|
+
response.
|
|
105
|
+
values (MutableSequence[google.protobuf.struct_pb2.Value]):
|
|
106
|
+
A streamed result set consists of a stream of values, which
|
|
107
|
+
might be split into many ``PartialResultSet`` messages to
|
|
108
|
+
accommodate large rows and/or large values. Every N complete
|
|
109
|
+
values defines a row, where N is equal to the number of
|
|
110
|
+
entries in
|
|
111
|
+
[metadata.row_type.fields][google.spanner.v1.StructType.fields].
|
|
112
|
+
|
|
113
|
+
Most values are encoded based on type as described
|
|
114
|
+
[here][google.spanner.v1.TypeCode].
|
|
115
|
+
|
|
116
|
+
It's possible that the last value in values is "chunked",
|
|
117
|
+
meaning that the rest of the value is sent in subsequent
|
|
118
|
+
``PartialResultSet``\ (s). This is denoted by the
|
|
119
|
+
[chunked_value][google.spanner.v1.PartialResultSet.chunked_value]
|
|
120
|
+
field. Two or more chunked values can be merged to form a
|
|
121
|
+
complete value as follows:
|
|
122
|
+
|
|
123
|
+
- ``bool/number/null``: can't be chunked
|
|
124
|
+
- ``string``: concatenate the strings
|
|
125
|
+
- ``list``: concatenate the lists. If the last element in a
|
|
126
|
+
list is a ``string``, ``list``, or ``object``, merge it
|
|
127
|
+
with the first element in the next list by applying these
|
|
128
|
+
rules recursively.
|
|
129
|
+
- ``object``: concatenate the (field name, field value)
|
|
130
|
+
pairs. If a field name is duplicated, then apply these
|
|
131
|
+
rules recursively to merge the field values.
|
|
132
|
+
|
|
133
|
+
Some examples of merging:
|
|
134
|
+
|
|
135
|
+
::
|
|
136
|
+
|
|
137
|
+
Strings are concatenated.
|
|
138
|
+
"foo", "bar" => "foobar"
|
|
139
|
+
|
|
140
|
+
Lists of non-strings are concatenated.
|
|
141
|
+
[2, 3], [4] => [2, 3, 4]
|
|
142
|
+
|
|
143
|
+
Lists are concatenated, but the last and first elements are merged
|
|
144
|
+
because they are strings.
|
|
145
|
+
["a", "b"], ["c", "d"] => ["a", "bc", "d"]
|
|
146
|
+
|
|
147
|
+
Lists are concatenated, but the last and first elements are merged
|
|
148
|
+
because they are lists. Recursively, the last and first elements
|
|
149
|
+
of the inner lists are merged because they are strings.
|
|
150
|
+
["a", ["b", "c"]], [["d"], "e"] => ["a", ["b", "cd"], "e"]
|
|
151
|
+
|
|
152
|
+
Non-overlapping object fields are combined.
|
|
153
|
+
{"a": "1"}, {"b": "2"} => {"a": "1", "b": 2"}
|
|
154
|
+
|
|
155
|
+
Overlapping object fields are merged.
|
|
156
|
+
{"a": "1"}, {"a": "2"} => {"a": "12"}
|
|
157
|
+
|
|
158
|
+
Examples of merging objects containing lists of strings.
|
|
159
|
+
{"a": ["1"]}, {"a": ["2"]} => {"a": ["12"]}
|
|
160
|
+
|
|
161
|
+
For a more complete example, suppose a streaming SQL query
|
|
162
|
+
is yielding a result set whose rows contain a single string
|
|
163
|
+
field. The following ``PartialResultSet``\ s might be
|
|
164
|
+
yielded:
|
|
165
|
+
|
|
166
|
+
::
|
|
167
|
+
|
|
168
|
+
{
|
|
169
|
+
"metadata": { ... }
|
|
170
|
+
"values": ["Hello", "W"]
|
|
171
|
+
"chunked_value": true
|
|
172
|
+
"resume_token": "Af65..."
|
|
173
|
+
}
|
|
174
|
+
{
|
|
175
|
+
"values": ["orl"]
|
|
176
|
+
"chunked_value": true
|
|
177
|
+
}
|
|
178
|
+
{
|
|
179
|
+
"values": ["d"]
|
|
180
|
+
"resume_token": "Zx1B..."
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
This sequence of ``PartialResultSet``\ s encodes two rows,
|
|
184
|
+
one containing the field value ``"Hello"``, and a second
|
|
185
|
+
containing the field value ``"World" = "W" + "orl" + "d"``.
|
|
186
|
+
|
|
187
|
+
Not all ``PartialResultSet``\ s contain a ``resume_token``.
|
|
188
|
+
Execution can only be resumed from a previously yielded
|
|
189
|
+
``resume_token``. For the above sequence of
|
|
190
|
+
``PartialResultSet``\ s, resuming the query with
|
|
191
|
+
``"resume_token": "Af65..."`` yields results from the
|
|
192
|
+
``PartialResultSet`` with value "orl".
|
|
193
|
+
chunked_value (bool):
|
|
194
|
+
If true, then the final value in
|
|
195
|
+
[values][google.spanner.v1.PartialResultSet.values] is
|
|
196
|
+
chunked, and must be combined with more values from
|
|
197
|
+
subsequent ``PartialResultSet``\ s to obtain a complete
|
|
198
|
+
field value.
|
|
199
|
+
resume_token (bytes):
|
|
200
|
+
Streaming calls might be interrupted for a variety of
|
|
201
|
+
reasons, such as TCP connection loss. If this occurs, the
|
|
202
|
+
stream of results can be resumed by re-sending the original
|
|
203
|
+
request and including ``resume_token``. Note that executing
|
|
204
|
+
any other transaction in the same session invalidates the
|
|
205
|
+
token.
|
|
206
|
+
stats (google.cloud.spanner_v1.types.ResultSetStats):
|
|
207
|
+
Query plan and execution statistics for the statement that
|
|
208
|
+
produced this streaming result set. These can be requested
|
|
209
|
+
by setting
|
|
210
|
+
[ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode]
|
|
211
|
+
and are sent only once with the last response in the stream.
|
|
212
|
+
This field is also present in the last response for DML
|
|
213
|
+
statements.
|
|
214
|
+
precommit_token (google.cloud.spanner_v1.types.MultiplexedSessionPrecommitToken):
|
|
215
|
+
Optional. A precommit token is included if the read-write
|
|
216
|
+
transaction has multiplexed sessions enabled. Pass the
|
|
217
|
+
precommit token with the highest sequence number from this
|
|
218
|
+
transaction attempt to the
|
|
219
|
+
[Commit][google.spanner.v1.Spanner.Commit] request for this
|
|
220
|
+
transaction.
|
|
221
|
+
last (bool):
|
|
222
|
+
Optional. Indicates whether this is the last
|
|
223
|
+
``PartialResultSet`` in the stream. The server might
|
|
224
|
+
optionally set this field. Clients shouldn't rely on this
|
|
225
|
+
field being set in all cases.
|
|
226
|
+
"""
|
|
227
|
+
|
|
228
|
+
metadata: "ResultSetMetadata" = proto.Field(
|
|
229
|
+
proto.MESSAGE,
|
|
230
|
+
number=1,
|
|
231
|
+
message="ResultSetMetadata",
|
|
232
|
+
)
|
|
233
|
+
values: MutableSequence[struct_pb2.Value] = proto.RepeatedField(
|
|
234
|
+
proto.MESSAGE,
|
|
235
|
+
number=2,
|
|
236
|
+
message=struct_pb2.Value,
|
|
237
|
+
)
|
|
238
|
+
chunked_value: bool = proto.Field(
|
|
239
|
+
proto.BOOL,
|
|
240
|
+
number=3,
|
|
241
|
+
)
|
|
242
|
+
resume_token: bytes = proto.Field(
|
|
243
|
+
proto.BYTES,
|
|
244
|
+
number=4,
|
|
245
|
+
)
|
|
246
|
+
stats: "ResultSetStats" = proto.Field(
|
|
247
|
+
proto.MESSAGE,
|
|
248
|
+
number=5,
|
|
249
|
+
message="ResultSetStats",
|
|
250
|
+
)
|
|
251
|
+
precommit_token: gs_transaction.MultiplexedSessionPrecommitToken = proto.Field(
|
|
252
|
+
proto.MESSAGE,
|
|
253
|
+
number=8,
|
|
254
|
+
message=gs_transaction.MultiplexedSessionPrecommitToken,
|
|
255
|
+
)
|
|
256
|
+
last: bool = proto.Field(
|
|
257
|
+
proto.BOOL,
|
|
258
|
+
number=9,
|
|
259
|
+
)
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
class ResultSetMetadata(proto.Message):
|
|
263
|
+
r"""Metadata about a [ResultSet][google.spanner.v1.ResultSet] or
|
|
264
|
+
[PartialResultSet][google.spanner.v1.PartialResultSet].
|
|
265
|
+
|
|
266
|
+
Attributes:
|
|
267
|
+
row_type (google.cloud.spanner_v1.types.StructType):
|
|
268
|
+
Indicates the field names and types for the rows in the
|
|
269
|
+
result set. For example, a SQL query like
|
|
270
|
+
``"SELECT UserId, UserName FROM Users"`` could return a
|
|
271
|
+
``row_type`` value like:
|
|
272
|
+
|
|
273
|
+
::
|
|
274
|
+
|
|
275
|
+
"fields": [
|
|
276
|
+
{ "name": "UserId", "type": { "code": "INT64" } },
|
|
277
|
+
{ "name": "UserName", "type": { "code": "STRING" } },
|
|
278
|
+
]
|
|
279
|
+
transaction (google.cloud.spanner_v1.types.Transaction):
|
|
280
|
+
If the read or SQL query began a transaction
|
|
281
|
+
as a side-effect, the information about the new
|
|
282
|
+
transaction is yielded here.
|
|
283
|
+
undeclared_parameters (google.cloud.spanner_v1.types.StructType):
|
|
284
|
+
A SQL query can be parameterized. In PLAN mode, these
|
|
285
|
+
parameters can be undeclared. This indicates the field names
|
|
286
|
+
and types for those undeclared parameters in the SQL query.
|
|
287
|
+
For example, a SQL query like
|
|
288
|
+
``"SELECT * FROM Users where UserId = @userId and UserName = @userName "``
|
|
289
|
+
could return a ``undeclared_parameters`` value like:
|
|
290
|
+
|
|
291
|
+
::
|
|
292
|
+
|
|
293
|
+
"fields": [
|
|
294
|
+
{ "name": "UserId", "type": { "code": "INT64" } },
|
|
295
|
+
{ "name": "UserName", "type": { "code": "STRING" } },
|
|
296
|
+
]
|
|
297
|
+
"""
|
|
298
|
+
|
|
299
|
+
row_type: gs_type.StructType = proto.Field(
|
|
300
|
+
proto.MESSAGE,
|
|
301
|
+
number=1,
|
|
302
|
+
message=gs_type.StructType,
|
|
303
|
+
)
|
|
304
|
+
transaction: gs_transaction.Transaction = proto.Field(
|
|
305
|
+
proto.MESSAGE,
|
|
306
|
+
number=2,
|
|
307
|
+
message=gs_transaction.Transaction,
|
|
308
|
+
)
|
|
309
|
+
undeclared_parameters: gs_type.StructType = proto.Field(
|
|
310
|
+
proto.MESSAGE,
|
|
311
|
+
number=3,
|
|
312
|
+
message=gs_type.StructType,
|
|
313
|
+
)
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
class ResultSetStats(proto.Message):
|
|
317
|
+
r"""Additional statistics about a
|
|
318
|
+
[ResultSet][google.spanner.v1.ResultSet] or
|
|
319
|
+
[PartialResultSet][google.spanner.v1.PartialResultSet].
|
|
320
|
+
|
|
321
|
+
This message has `oneof`_ fields (mutually exclusive fields).
|
|
322
|
+
For each oneof, at most one member field can be set at the same time.
|
|
323
|
+
Setting any member of the oneof automatically clears all other
|
|
324
|
+
members.
|
|
325
|
+
|
|
326
|
+
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
|
|
327
|
+
|
|
328
|
+
Attributes:
|
|
329
|
+
query_plan (google.cloud.spanner_v1.types.QueryPlan):
|
|
330
|
+
[QueryPlan][google.spanner.v1.QueryPlan] for the query
|
|
331
|
+
associated with this result.
|
|
332
|
+
query_stats (google.protobuf.struct_pb2.Struct):
|
|
333
|
+
Aggregated statistics from the execution of the query. Only
|
|
334
|
+
present when the query is profiled. For example, a query
|
|
335
|
+
could return the statistics as follows:
|
|
336
|
+
|
|
337
|
+
::
|
|
338
|
+
|
|
339
|
+
{
|
|
340
|
+
"rows_returned": "3",
|
|
341
|
+
"elapsed_time": "1.22 secs",
|
|
342
|
+
"cpu_time": "1.19 secs"
|
|
343
|
+
}
|
|
344
|
+
row_count_exact (int):
|
|
345
|
+
Standard DML returns an exact count of rows
|
|
346
|
+
that were modified.
|
|
347
|
+
|
|
348
|
+
This field is a member of `oneof`_ ``row_count``.
|
|
349
|
+
row_count_lower_bound (int):
|
|
350
|
+
Partitioned DML doesn't offer exactly-once
|
|
351
|
+
semantics, so it returns a lower bound of the
|
|
352
|
+
rows modified.
|
|
353
|
+
|
|
354
|
+
This field is a member of `oneof`_ ``row_count``.
|
|
355
|
+
"""
|
|
356
|
+
|
|
357
|
+
query_plan: gs_query_plan.QueryPlan = proto.Field(
|
|
358
|
+
proto.MESSAGE,
|
|
359
|
+
number=1,
|
|
360
|
+
message=gs_query_plan.QueryPlan,
|
|
361
|
+
)
|
|
362
|
+
query_stats: struct_pb2.Struct = proto.Field(
|
|
363
|
+
proto.MESSAGE,
|
|
364
|
+
number=2,
|
|
365
|
+
message=struct_pb2.Struct,
|
|
366
|
+
)
|
|
367
|
+
row_count_exact: int = proto.Field(
|
|
368
|
+
proto.INT64,
|
|
369
|
+
number=3,
|
|
370
|
+
oneof="row_count",
|
|
371
|
+
)
|
|
372
|
+
row_count_lower_bound: int = proto.Field(
|
|
373
|
+
proto.INT64,
|
|
374
|
+
number=4,
|
|
375
|
+
oneof="row_count",
|
|
376
|
+
)
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
__all__ = tuple(sorted(__protobuf__.manifest))
|