Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(spanner): add directed_read_option in spanner.proto #1030

Merged
merged 2 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 24 additions & 21 deletions google/cloud/spanner_v1/services/spanner/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ async def sample_batch_create_sessions():
Returns:
google.cloud.spanner_v1.types.BatchCreateSessionsResponse:
The response for
[BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions].
[BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions].

"""
# Create or coerce a protobuf request object.
Expand Down Expand Up @@ -1075,8 +1075,10 @@ async def sample_execute_batch_dml():

Returns:
google.cloud.spanner_v1.types.ExecuteBatchDmlResponse:
The response for [ExecuteBatchDml][google.spanner.v1.Spanner.ExecuteBatchDml]. Contains a list
of [ResultSet][google.spanner.v1.ResultSet] messages,
The response for
[ExecuteBatchDml][google.spanner.v1.Spanner.ExecuteBatchDml].
Contains a list of
[ResultSet][google.spanner.v1.ResultSet] messages,
one for each DML statement that has successfully
executed, in the same order as the statements in the
request. If a statement fails, the status in the
Expand All @@ -1086,34 +1088,35 @@ async def sample_execute_batch_dml():
following approach:

1. Check the status in the response message. The
[google.rpc.Code][google.rpc.Code] enum value OK
indicates that all statements were executed
successfully.
2. If the status was not OK, check the number of
result sets in the response. If the response
contains N
[ResultSet][google.spanner.v1.ResultSet] messages,
then statement N+1 in the request failed.
[google.rpc.Code][google.rpc.Code] enum value OK
indicates that all statements were executed
successfully. 2. If the status was not OK, check the
number of result sets in the response. If the
response contains N
[ResultSet][google.spanner.v1.ResultSet] messages,
then statement N+1 in the request failed.

Example 1:

- Request: 5 DML statements, all executed
successfully.
- Response: 5
[ResultSet][google.spanner.v1.ResultSet] messages,
with the status OK.

\* Response: 5
[ResultSet][google.spanner.v1.ResultSet] messages,
with the status OK.

Example 2:

- Request: 5 DML statements. The third statement has
a syntax error.
- Response: 2
[ResultSet][google.spanner.v1.ResultSet] messages,
and a syntax error (INVALID_ARGUMENT) status. The
number of [ResultSet][google.spanner.v1.ResultSet]
messages indicates that the third statement
failed, and the fourth and fifth statements were
not executed.

\* Response: 2
[ResultSet][google.spanner.v1.ResultSet] messages,
and a syntax error (INVALID_ARGUMENT) status. The
number of [ResultSet][google.spanner.v1.ResultSet]
messages indicates that the third statement failed,
and the fourth and fifth statements were not
executed.

"""
# Create or coerce a protobuf request object.
Expand Down
45 changes: 24 additions & 21 deletions google/cloud/spanner_v1/services/spanner/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ def sample_batch_create_sessions():
Returns:
google.cloud.spanner_v1.types.BatchCreateSessionsResponse:
The response for
[BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions].
[BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions].

"""
# Create or coerce a protobuf request object.
Expand Down Expand Up @@ -1279,8 +1279,10 @@ def sample_execute_batch_dml():

Returns:
google.cloud.spanner_v1.types.ExecuteBatchDmlResponse:
The response for [ExecuteBatchDml][google.spanner.v1.Spanner.ExecuteBatchDml]. Contains a list
of [ResultSet][google.spanner.v1.ResultSet] messages,
The response for
[ExecuteBatchDml][google.spanner.v1.Spanner.ExecuteBatchDml].
Contains a list of
[ResultSet][google.spanner.v1.ResultSet] messages,
one for each DML statement that has successfully
executed, in the same order as the statements in the
request. If a statement fails, the status in the
Expand All @@ -1290,34 +1292,35 @@ def sample_execute_batch_dml():
following approach:

1. Check the status in the response message. The
[google.rpc.Code][google.rpc.Code] enum value OK
indicates that all statements were executed
successfully.
2. If the status was not OK, check the number of
result sets in the response. If the response
contains N
[ResultSet][google.spanner.v1.ResultSet] messages,
then statement N+1 in the request failed.
[google.rpc.Code][google.rpc.Code] enum value OK
indicates that all statements were executed
successfully. 2. If the status was not OK, check the
number of result sets in the response. If the
response contains N
[ResultSet][google.spanner.v1.ResultSet] messages,
then statement N+1 in the request failed.

Example 1:

- Request: 5 DML statements, all executed
successfully.
- Response: 5
[ResultSet][google.spanner.v1.ResultSet] messages,
with the status OK.

\* Response: 5
[ResultSet][google.spanner.v1.ResultSet] messages,
with the status OK.

Example 2:

- Request: 5 DML statements. The third statement has
a syntax error.
- Response: 2
[ResultSet][google.spanner.v1.ResultSet] messages,
and a syntax error (INVALID_ARGUMENT) status. The
number of [ResultSet][google.spanner.v1.ResultSet]
messages indicates that the third statement
failed, and the fourth and fifth statements were
not executed.

\* Response: 2
[ResultSet][google.spanner.v1.ResultSet] messages,
and a syntax error (INVALID_ARGUMENT) status. The
number of [ResultSet][google.spanner.v1.ResultSet]
messages indicates that the third statement failed,
and the fourth and fifth statements were not
executed.

"""
# Create or coerce a protobuf request object.
Expand Down
2 changes: 2 additions & 0 deletions google/cloud/spanner_v1/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
CommitRequest,
CreateSessionRequest,
DeleteSessionRequest,
DirectedReadOptions,
ExecuteBatchDmlRequest,
ExecuteBatchDmlResponse,
ExecuteSqlRequest,
Expand Down Expand Up @@ -89,6 +90,7 @@
"CommitRequest",
"CreateSessionRequest",
"DeleteSessionRequest",
"DirectedReadOptions",
"ExecuteBatchDmlRequest",
"ExecuteBatchDmlResponse",
"ExecuteSqlRequest",
Expand Down
Loading