Batches the supplied mutation groups in a collection of efficient
transactions. All mutations in a group are committed atomically.
However, mutations across groups can be committed non-atomically in an
unspecified order and thus, they must be independent of each other.
Partial failure is possible, that is, some groups might have been
committed successfully, while some might have failed. The results of
individual batches are streamed into the response as the batches are
applied. BatchWrite
requests are not replay protected, meaning that
each mutation group can be applied more than once. Replays of
non-idempotent mutations can have undesirable effects. For example,
replays of an insert mutation can produce an already exists error or if
you use generated or commit timestamp-based keys, it can result in
additional rows being added to the mutation's table. We recommend
structuring your mutation groups to be idempotent to avoid this issue.
For more information about retries and long-running operations, see Understand connectors.
Arguments
Parameters | |
---|---|
session |
Required. The session in which the batch request is to be run. |
body |
Required. |
Raised exceptions
Exceptions | |
---|---|
ConnectionError |
In case of a network problem (such as DNS failure or refused connection). |
HttpError |
If the response status is >= 400 (excluding 429 and 503). |
TimeoutError |
If a long-running operation takes longer to finish than the specified timeout limit. |
TypeError |
If an operation or function receives an argument of the wrong type. |
ValueError |
If an operation or function receives an argument of the right type but an inappropriate value. For example, a negative timeout. |
Response
If successful, the response contains an instance of BatchWriteResponse
.
Subworkflow snippet
Some fields might be optional or required. To identify required fields, refer to the API documentation.
YAML
- batchWrite: call: googleapis.spanner.v1.projects.instances.databases.sessions.batchWrite args: session: ... body: excludeTxnFromChangeStreams: ... mutationGroups: ... requestOptions: priority: ... requestTag: ... transactionTag: ... result: batchWriteResult
JSON
[ { "batchWrite": { "call": "googleapis.spanner.v1.projects.instances.databases.sessions.batchWrite", "args": { "session": "...", "body": { "excludeTxnFromChangeStreams": "...", "mutationGroups": "...", "requestOptions": { "priority": "...", "requestTag": "...", "transactionTag": "..." } } }, "result": "batchWriteResult" } } ]