@google-cloud/spanner 7.0.0 → 7.1.0

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.
@@ -1,4 +1,4 @@
1
- // Copyright 2022 Google LLC
1
+ // Copyright 2023 Google LLC
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -16,6 +16,8 @@ syntax = "proto3";
16
16
 
17
17
  package google.spanner.v1;
18
18
 
19
+ import public "google/spanner/v1/commit_response.proto";
20
+
19
21
  import "google/api/annotations.proto";
20
22
  import "google/api/client.proto";
21
23
  import "google/api/field_behavior.proto";
@@ -24,7 +26,6 @@ import "google/protobuf/empty.proto";
24
26
  import "google/protobuf/struct.proto";
25
27
  import "google/protobuf/timestamp.proto";
26
28
  import "google/rpc/status.proto";
27
- import public "google/spanner/v1/commit_response.proto";
28
29
  import "google/spanner/v1/keys.proto";
29
30
  import "google/spanner/v1/mutation.proto";
30
31
  import "google/spanner/v1/result_set.proto";
@@ -84,7 +85,8 @@ service Spanner {
84
85
  //
85
86
  // This API can be used to initialize a session cache on the clients.
86
87
  // See https://goo.gl/TgSFN2 for best practices on session cache management.
87
- rpc BatchCreateSessions(BatchCreateSessionsRequest) returns (BatchCreateSessionsResponse) {
88
+ rpc BatchCreateSessions(BatchCreateSessionsRequest)
89
+ returns (BatchCreateSessionsResponse) {
88
90
  option (google.api.http) = {
89
91
  post: "/v1/{database=projects/*/instances/*/databases/*}/sessions:batchCreate"
90
92
  body: "*"
@@ -127,10 +129,12 @@ service Spanner {
127
129
  //
128
130
  // Operations inside read-write transactions might return `ABORTED`. If
129
131
  // this occurs, the application should restart the transaction from
130
- // the beginning. See [Transaction][google.spanner.v1.Transaction] for more details.
132
+ // the beginning. See [Transaction][google.spanner.v1.Transaction] for more
133
+ // details.
131
134
  //
132
135
  // Larger result sets can be fetched in streaming fashion by calling
133
- // [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] instead.
136
+ // [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql]
137
+ // instead.
134
138
  rpc ExecuteSql(ExecuteSqlRequest) returns (ResultSet) {
135
139
  option (google.api.http) = {
136
140
  post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:executeSql"
@@ -138,11 +142,11 @@ service Spanner {
138
142
  };
139
143
  }
140
144
 
141
- // Like [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql], except returns the result
142
- // set as a stream. Unlike [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql], there
143
- // is no limit on the size of the returned result set. However, no
144
- // individual row in the result set can exceed 100 MiB, and no
145
- // column value can exceed 10 MiB.
145
+ // Like [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql], except returns the
146
+ // result set as a stream. Unlike
147
+ // [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql], there is no limit on
148
+ // the size of the returned result set. However, no individual row in the
149
+ // result set can exceed 100 MiB, and no column value can exceed 10 MiB.
146
150
  rpc ExecuteStreamingSql(ExecuteSqlRequest) returns (stream PartialResultSet) {
147
151
  option (google.api.http) = {
148
152
  post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:executeStreamingSql"
@@ -155,13 +159,15 @@ service Spanner {
155
159
  // [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql].
156
160
  //
157
161
  // Statements are executed in sequential order. A request can succeed even if
158
- // a statement fails. The [ExecuteBatchDmlResponse.status][google.spanner.v1.ExecuteBatchDmlResponse.status] field in the
159
- // response provides information about the statement that failed. Clients must
160
- // inspect this field to determine whether an error occurred.
162
+ // a statement fails. The
163
+ // [ExecuteBatchDmlResponse.status][google.spanner.v1.ExecuteBatchDmlResponse.status]
164
+ // field in the response provides information about the statement that failed.
165
+ // Clients must inspect this field to determine whether an error occurred.
161
166
  //
162
167
  // Execution stops after the first failed statement; the remaining statements
163
168
  // are not executed.
164
- rpc ExecuteBatchDml(ExecuteBatchDmlRequest) returns (ExecuteBatchDmlResponse) {
169
+ rpc ExecuteBatchDml(ExecuteBatchDmlRequest)
170
+ returns (ExecuteBatchDmlResponse) {
165
171
  option (google.api.http) = {
166
172
  post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:executeBatchDml"
167
173
  body: "*"
@@ -170,14 +176,15 @@ service Spanner {
170
176
 
171
177
  // Reads rows from the database using key lookups and scans, as a
172
178
  // simple key/value style alternative to
173
- // [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql]. This method cannot be used to
174
- // return a result set larger than 10 MiB; if the read matches more
179
+ // [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql]. This method cannot be
180
+ // used to return a result set larger than 10 MiB; if the read matches more
175
181
  // data than that, the read fails with a `FAILED_PRECONDITION`
176
182
  // error.
177
183
  //
178
184
  // Reads inside read-write transactions might return `ABORTED`. If
179
185
  // this occurs, the application should restart the transaction from
180
- // the beginning. See [Transaction][google.spanner.v1.Transaction] for more details.
186
+ // the beginning. See [Transaction][google.spanner.v1.Transaction] for more
187
+ // details.
181
188
  //
182
189
  // Larger result sets can be yielded in streaming fashion by calling
183
190
  // [StreamingRead][google.spanner.v1.Spanner.StreamingRead] instead.
@@ -188,9 +195,9 @@ service Spanner {
188
195
  };
189
196
  }
190
197
 
191
- // Like [Read][google.spanner.v1.Spanner.Read], except returns the result set as a
192
- // stream. Unlike [Read][google.spanner.v1.Spanner.Read], there is no limit on the
193
- // size of the returned result set. However, no individual row in
198
+ // Like [Read][google.spanner.v1.Spanner.Read], except returns the result set
199
+ // as a stream. Unlike [Read][google.spanner.v1.Spanner.Read], there is no
200
+ // limit on the size of the returned result set. However, no individual row in
194
201
  // the result set can exceed 100 MiB, and no column value can exceed
195
202
  // 10 MiB.
196
203
  rpc StreamingRead(ReadRequest) returns (stream PartialResultSet) {
@@ -201,7 +208,8 @@ service Spanner {
201
208
  }
202
209
 
203
210
  // Begins a new transaction. This step can often be skipped:
204
- // [Read][google.spanner.v1.Spanner.Read], [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and
211
+ // [Read][google.spanner.v1.Spanner.Read],
212
+ // [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and
205
213
  // [Commit][google.spanner.v1.Spanner.Commit] can begin a new transaction as a
206
214
  // side-effect.
207
215
  rpc BeginTransaction(BeginTransactionRequest) returns (Transaction) {
@@ -232,13 +240,15 @@ service Spanner {
232
240
  body: "*"
233
241
  };
234
242
  option (google.api.method_signature) = "session,transaction_id,mutations";
235
- option (google.api.method_signature) = "session,single_use_transaction,mutations";
243
+ option (google.api.method_signature) =
244
+ "session,single_use_transaction,mutations";
236
245
  }
237
246
 
238
247
  // Rolls back a transaction, releasing any locks it holds. It is a good
239
248
  // idea to call this for any transaction that includes one or more
240
- // [Read][google.spanner.v1.Spanner.Read] or [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] requests and
241
- // ultimately decides not to commit.
249
+ // [Read][google.spanner.v1.Spanner.Read] or
250
+ // [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] requests and ultimately
251
+ // decides not to commit.
242
252
  //
243
253
  // `Rollback` returns `OK` if it successfully aborts the transaction, the
244
254
  // transaction was already aborted, or the transaction is not
@@ -253,10 +263,11 @@ service Spanner {
253
263
 
254
264
  // Creates a set of partition tokens that can be used to execute a query
255
265
  // operation in parallel. Each of the returned partition tokens can be used
256
- // by [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] to specify a subset
257
- // of the query result to read. The same session and read-only transaction
258
- // must be used by the PartitionQueryRequest used to create the
259
- // partition tokens and the ExecuteSqlRequests that use the partition tokens.
266
+ // by [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] to
267
+ // specify a subset of the query result to read. The same session and
268
+ // read-only transaction must be used by the PartitionQueryRequest used to
269
+ // create the partition tokens and the ExecuteSqlRequests that use the
270
+ // partition tokens.
260
271
  //
261
272
  // Partition tokens become invalid when the session used to create them
262
273
  // is deleted, is idle for too long, begins a new transaction, or becomes too
@@ -271,12 +282,13 @@ service Spanner {
271
282
 
272
283
  // Creates a set of partition tokens that can be used to execute a read
273
284
  // operation in parallel. Each of the returned partition tokens can be used
274
- // by [StreamingRead][google.spanner.v1.Spanner.StreamingRead] to specify a subset of the read
275
- // result to read. The same session and read-only transaction must be used by
276
- // the PartitionReadRequest used to create the partition tokens and the
277
- // ReadRequests that use the partition tokens. There are no ordering
278
- // guarantees on rows returned among the returned partition tokens, or even
279
- // within each individual StreamingRead call issued with a partition_token.
285
+ // by [StreamingRead][google.spanner.v1.Spanner.StreamingRead] to specify a
286
+ // subset of the read result to read. The same session and read-only
287
+ // transaction must be used by the PartitionReadRequest used to create the
288
+ // partition tokens and the ReadRequests that use the partition tokens. There
289
+ // are no ordering guarantees on rows returned among the returned partition
290
+ // tokens, or even within each individual StreamingRead call issued with a
291
+ // partition_token.
280
292
  //
281
293
  // Partition tokens become invalid when the session used to create them
282
294
  // is deleted, is idle for too long, begins a new transaction, or becomes too
@@ -288,6 +300,29 @@ service Spanner {
288
300
  body: "*"
289
301
  };
290
302
  }
303
+
304
+ // Batches the supplied mutation groups in a collection of efficient
305
+ // transactions. All mutations in a group are committed atomically. However,
306
+ // mutations across groups can be committed non-atomically in an unspecified
307
+ // order and thus, they must be independent of each other. Partial failure is
308
+ // possible, i.e., some groups may have been committed successfully, while
309
+ // some may have failed. The results of individual batches are streamed into
310
+ // the response as the batches are applied.
311
+ //
312
+ // BatchWrite requests are not replay protected, meaning that each mutation
313
+ // group may be applied more than once. Replays of non-idempotent mutations
314
+ // may have undesirable effects. For example, replays of an insert mutation
315
+ // may produce an already exists error or if you use generated or commit
316
+ // timestamp-based keys, it may result in additional rows being added to the
317
+ // mutation's table. We recommend structuring your mutation groups to be
318
+ // idempotent to avoid this issue.
319
+ rpc BatchWrite(BatchWriteRequest) returns (stream BatchWriteResponse) {
320
+ option (google.api.http) = {
321
+ post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:batchWrite"
322
+ body: "*"
323
+ };
324
+ option (google.api.method_signature) = "session,mutation_groups";
325
+ }
291
326
  }
292
327
 
293
328
  // The request for [CreateSession][google.spanner.v1.Spanner.CreateSession].
@@ -304,7 +339,8 @@ message CreateSessionRequest {
304
339
  Session session = 2 [(google.api.field_behavior) = REQUIRED];
305
340
  }
306
341
 
307
- // The request for [BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions].
342
+ // The request for
343
+ // [BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions].
308
344
  message BatchCreateSessionsRequest {
309
345
  // Required. The database in which the new sessions are created.
310
346
  string database = 1 [
@@ -321,11 +357,13 @@ message BatchCreateSessionsRequest {
321
357
  // The API may return fewer than the requested number of sessions. If a
322
358
  // specific number of sessions are desired, the client can make additional
323
359
  // calls to BatchCreateSessions (adjusting
324
- // [session_count][google.spanner.v1.BatchCreateSessionsRequest.session_count] as necessary).
360
+ // [session_count][google.spanner.v1.BatchCreateSessionsRequest.session_count]
361
+ // as necessary).
325
362
  int32 session_count = 3 [(google.api.field_behavior) = REQUIRED];
326
363
  }
327
364
 
328
- // The response for [BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions].
365
+ // The response for
366
+ // [BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions].
329
367
  message BatchCreateSessionsResponse {
330
368
  // The freshly created sessions.
331
369
  repeated Session session = 1;
@@ -353,11 +391,13 @@ message Session {
353
391
  map<string, string> labels = 2;
354
392
 
355
393
  // Output only. The timestamp when the session is created.
356
- google.protobuf.Timestamp create_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
394
+ google.protobuf.Timestamp create_time = 3
395
+ [(google.api.field_behavior) = OUTPUT_ONLY];
357
396
 
358
397
  // Output only. The approximate timestamp when the session is last used. It is
359
398
  // typically earlier than the actual last use time.
360
- google.protobuf.Timestamp approximate_last_use_time = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
399
+ google.protobuf.Timestamp approximate_last_use_time = 4
400
+ [(google.api.field_behavior) = OUTPUT_ONLY];
361
401
 
362
402
  // The database role which created this session.
363
403
  string creator_role = 5;
@@ -368,9 +408,7 @@ message GetSessionRequest {
368
408
  // Required. The name of the session to retrieve.
369
409
  string name = 1 [
370
410
  (google.api.field_behavior) = REQUIRED,
371
- (google.api.resource_reference) = {
372
- type: "spanner.googleapis.com/Session"
373
- }
411
+ (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" }
374
412
  ];
375
413
  }
376
414
 
@@ -389,7 +427,8 @@ message ListSessionsRequest {
389
427
  int32 page_size = 2;
390
428
 
391
429
  // If non-empty, `page_token` should contain a
392
- // [next_page_token][google.spanner.v1.ListSessionsResponse.next_page_token] from a previous
430
+ // [next_page_token][google.spanner.v1.ListSessionsResponse.next_page_token]
431
+ // from a previous
393
432
  // [ListSessionsResponse][google.spanner.v1.ListSessionsResponse].
394
433
  string page_token = 3;
395
434
 
@@ -412,8 +451,8 @@ message ListSessionsResponse {
412
451
  repeated Session sessions = 1;
413
452
 
414
453
  // `next_page_token` can be sent in a subsequent
415
- // [ListSessions][google.spanner.v1.Spanner.ListSessions] call to fetch more of the matching
416
- // sessions.
454
+ // [ListSessions][google.spanner.v1.Spanner.ListSessions] call to fetch more
455
+ // of the matching sessions.
417
456
  string next_page_token = 2;
418
457
  }
419
458
 
@@ -422,9 +461,7 @@ message DeleteSessionRequest {
422
461
  // Required. The name of the session to delete.
423
462
  string name = 1 [
424
463
  (google.api.field_behavior) = REQUIRED,
425
- (google.api.resource_reference) = {
426
- type: "spanner.googleapis.com/Session"
427
- }
464
+ (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" }
428
465
  ];
429
466
  }
430
467
 
@@ -489,6 +526,86 @@ message RequestOptions {
489
526
  string transaction_tag = 3;
490
527
  }
491
528
 
529
+ // The DirectedReadOptions can be used to indicate which replicas or regions
530
+ // should be used for non-transactional reads or queries.
531
+ //
532
+ // DirectedReadOptions may only be specified for a read-only transaction,
533
+ // otherwise the API will return an `INVALID_ARGUMENT` error.
534
+ message DirectedReadOptions {
535
+ // The directed read replica selector.
536
+ // Callers must provide one or more of the following fields for replica
537
+ // selection:
538
+ //
539
+ // * `location` - The location must be one of the regions within the
540
+ // multi-region configuration of your database.
541
+ // * `type` - The type of the replica.
542
+ //
543
+ // Some examples of using replica_selectors are:
544
+ //
545
+ // * `location:us-east1` --> The "us-east1" replica(s) of any available type
546
+ // will be used to process the request.
547
+ // * `type:READ_ONLY` --> The "READ_ONLY" type replica(s) in nearest
548
+ // . available location will be used to process the
549
+ // request.
550
+ // * `location:us-east1 type:READ_ONLY` --> The "READ_ONLY" type replica(s)
551
+ // in location "us-east1" will be used to process
552
+ // the request.
553
+ message ReplicaSelection {
554
+ // Indicates the type of replica.
555
+ enum Type {
556
+ // Not specified.
557
+ TYPE_UNSPECIFIED = 0;
558
+
559
+ // Read-write replicas support both reads and writes.
560
+ READ_WRITE = 1;
561
+
562
+ // Read-only replicas only support reads (not writes).
563
+ READ_ONLY = 2;
564
+ }
565
+
566
+ // The location or region of the serving requests, e.g. "us-east1".
567
+ string location = 1;
568
+
569
+ // The type of replica.
570
+ Type type = 2;
571
+ }
572
+
573
+ // An IncludeReplicas contains a repeated set of ReplicaSelection which
574
+ // indicates the order in which replicas should be considered.
575
+ message IncludeReplicas {
576
+ // The directed read replica selector.
577
+ repeated ReplicaSelection replica_selections = 1;
578
+
579
+ // If true, Spanner will not route requests to a replica outside the
580
+ // include_replicas list when all of the specified replicas are unavailable
581
+ // or unhealthy. Default value is `false`.
582
+ bool auto_failover_disabled = 2;
583
+ }
584
+
585
+ // An ExcludeReplicas contains a repeated set of ReplicaSelection that should
586
+ // be excluded from serving requests.
587
+ message ExcludeReplicas {
588
+ // The directed read replica selector.
589
+ repeated ReplicaSelection replica_selections = 1;
590
+ }
591
+
592
+ // Required. Replicas indicates the order in which replicas should be
593
+ // considered. At most one of either include_replicas or exclude_replicas
594
+ // should be present in the message.
595
+ oneof replicas {
596
+ // Include_replicas indicates the order of replicas (as they appear in
597
+ // this list) to process the request. If auto_failover_disabled is set to
598
+ // true and all replicas are exhausted without finding a healthy replica,
599
+ // Spanner will wait for a replica in the list to become available, requests
600
+ // may fail due to `DEADLINE_EXCEEDED` errors.
601
+ IncludeReplicas include_replicas = 1;
602
+
603
+ // Exclude_replicas indicates that should be excluded from serving
604
+ // requests. Spanner will not route requests to the replicas in this list.
605
+ ExcludeReplicas exclude_replicas = 2;
606
+ }
607
+ }
608
+
492
609
  // The request for [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and
493
610
  // [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql].
494
611
  message ExecuteSqlRequest {
@@ -562,9 +679,7 @@ message ExecuteSqlRequest {
562
679
  // Required. The session in which the SQL query should be performed.
563
680
  string session = 1 [
564
681
  (google.api.field_behavior) = REQUIRED,
565
- (google.api.resource_reference) = {
566
- type: "spanner.googleapis.com/Session"
567
- }
682
+ (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" }
568
683
  ];
569
684
 
570
685
  // The transaction to use.
@@ -599,7 +714,8 @@ message ExecuteSqlRequest {
599
714
 
600
715
  // It is not always possible for Cloud Spanner to infer the right SQL type
601
716
  // from a JSON value. For example, values of type `BYTES` and values
602
- // of type `STRING` both appear in [params][google.spanner.v1.ExecuteSqlRequest.params] as JSON strings.
717
+ // of type `STRING` both appear in
718
+ // [params][google.spanner.v1.ExecuteSqlRequest.params] as JSON strings.
603
719
  //
604
720
  // In these cases, `param_types` can be used to specify the exact
605
721
  // SQL type for some or all of the SQL statement parameters. See the
@@ -609,15 +725,18 @@ message ExecuteSqlRequest {
609
725
 
610
726
  // If this request is resuming a previously interrupted SQL statement
611
727
  // execution, `resume_token` should be copied from the last
612
- // [PartialResultSet][google.spanner.v1.PartialResultSet] yielded before the interruption. Doing this
613
- // enables the new SQL statement execution to resume where the last one left
614
- // off. The rest of the request parameters must exactly match the
615
- // request that yielded this token.
728
+ // [PartialResultSet][google.spanner.v1.PartialResultSet] yielded before the
729
+ // interruption. Doing this enables the new SQL statement execution to resume
730
+ // where the last one left off. The rest of the request parameters must
731
+ // exactly match the request that yielded this token.
616
732
  bytes resume_token = 6;
617
733
 
618
734
  // Used to control the amount of debugging information returned in
619
- // [ResultSetStats][google.spanner.v1.ResultSetStats]. If [partition_token][google.spanner.v1.ExecuteSqlRequest.partition_token] is set, [query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode] can only
620
- // be set to [QueryMode.NORMAL][google.spanner.v1.ExecuteSqlRequest.QueryMode.NORMAL].
735
+ // [ResultSetStats][google.spanner.v1.ResultSetStats]. If
736
+ // [partition_token][google.spanner.v1.ExecuteSqlRequest.partition_token] is
737
+ // set, [query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode] can only
738
+ // be set to
739
+ // [QueryMode.NORMAL][google.spanner.v1.ExecuteSqlRequest.QueryMode.NORMAL].
621
740
  QueryMode query_mode = 7;
622
741
 
623
742
  // If present, results will be restricted to the specified partition
@@ -644,11 +763,14 @@ message ExecuteSqlRequest {
644
763
  // Common options for this request.
645
764
  RequestOptions request_options = 11;
646
765
 
766
+ // Directed read options for this request.
767
+ DirectedReadOptions directed_read_options = 15;
768
+
647
769
  // If this is for a partitioned query and this field is set to `true`, the
648
- // request will be executed via Spanner independent compute resources.
770
+ // request is executed with Spanner Data Boost independent compute resources.
649
771
  //
650
772
  // If the field is set to `true` but the request does not set
651
- // `partition_token`, the API will return an `INVALID_ARGUMENT` error.
773
+ // `partition_token`, the API returns an `INVALID_ARGUMENT` error.
652
774
  bool data_boost_enabled = 16;
653
775
  }
654
776
 
@@ -675,7 +797,9 @@ message ExecuteBatchDmlRequest {
675
797
 
676
798
  // It is not always possible for Cloud Spanner to infer the right SQL type
677
799
  // from a JSON value. For example, values of type `BYTES` and values
678
- // of type `STRING` both appear in [params][google.spanner.v1.ExecuteBatchDmlRequest.Statement.params] as JSON strings.
800
+ // of type `STRING` both appear in
801
+ // [params][google.spanner.v1.ExecuteBatchDmlRequest.Statement.params] as
802
+ // JSON strings.
679
803
  //
680
804
  // In these cases, `param_types` can be used to specify the exact
681
805
  // SQL type for some or all of the SQL statement parameters. See the
@@ -687,9 +811,7 @@ message ExecuteBatchDmlRequest {
687
811
  // Required. The session in which the DML statements should be performed.
688
812
  string session = 1 [
689
813
  (google.api.field_behavior) = REQUIRED,
690
- (google.api.resource_reference) = {
691
- type: "spanner.googleapis.com/Session"
692
- }
814
+ (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" }
693
815
  ];
694
816
 
695
817
  // Required. The transaction to use. Must be a read-write transaction.
@@ -699,17 +821,17 @@ message ExecuteBatchDmlRequest {
699
821
  // transaction.
700
822
  TransactionSelector transaction = 2 [(google.api.field_behavior) = REQUIRED];
701
823
 
702
- // Required. The list of statements to execute in this batch. Statements are executed
703
- // serially, such that the effects of statement `i` are visible to statement
704
- // `i+1`. Each statement must be a DML statement. Execution stops at the
705
- // first failed statement; the remaining statements are not executed.
824
+ // Required. The list of statements to execute in this batch. Statements are
825
+ // executed serially, such that the effects of statement `i` are visible to
826
+ // statement `i+1`. Each statement must be a DML statement. Execution stops at
827
+ // the first failed statement; the remaining statements are not executed.
706
828
  //
707
829
  // Callers must provide at least one statement.
708
830
  repeated Statement statements = 3 [(google.api.field_behavior) = REQUIRED];
709
831
 
710
- // Required. A per-transaction sequence number used to identify this request. This field
711
- // makes each request idempotent such that if the request is received multiple
712
- // times, at most one will succeed.
832
+ // Required. A per-transaction sequence number used to identify this request.
833
+ // This field makes each request idempotent such that if the request is
834
+ // received multiple times, at most one will succeed.
713
835
  //
714
836
  // The sequence number must be monotonically increasing within the
715
837
  // transaction. If a request arrives for the first time with an out-of-order
@@ -721,38 +843,47 @@ message ExecuteBatchDmlRequest {
721
843
  RequestOptions request_options = 5;
722
844
  }
723
845
 
724
- // The response for [ExecuteBatchDml][google.spanner.v1.Spanner.ExecuteBatchDml]. Contains a list
725
- // of [ResultSet][google.spanner.v1.ResultSet] messages, one for each DML statement that has successfully
726
- // executed, in the same order as the statements in the request. If a statement
727
- // fails, the status in the response body identifies the cause of the failure.
846
+ // The response for
847
+ // [ExecuteBatchDml][google.spanner.v1.Spanner.ExecuteBatchDml]. Contains a list
848
+ // of [ResultSet][google.spanner.v1.ResultSet] messages, one for each DML
849
+ // statement that has successfully executed, in the same order as the statements
850
+ // in the request. If a statement fails, the status in the response body
851
+ // identifies the cause of the failure.
728
852
  //
729
853
  // To check for DML statements that failed, use the following approach:
730
854
  //
731
- // 1. Check the status in the response message. The [google.rpc.Code][google.rpc.Code] enum
855
+ // 1. Check the status in the response message. The
856
+ // [google.rpc.Code][google.rpc.Code] enum
732
857
  // value `OK` indicates that all statements were executed successfully.
733
858
  // 2. If the status was not `OK`, check the number of result sets in the
734
- // response. If the response contains `N` [ResultSet][google.spanner.v1.ResultSet] messages, then
735
- // statement `N+1` in the request failed.
859
+ // response. If the response contains `N`
860
+ // [ResultSet][google.spanner.v1.ResultSet] messages, then statement `N+1` in
861
+ // the request failed.
736
862
  //
737
863
  // Example 1:
738
864
  //
739
865
  // * Request: 5 DML statements, all executed successfully.
740
- // * Response: 5 [ResultSet][google.spanner.v1.ResultSet] messages, with the status `OK`.
866
+ // * Response: 5 [ResultSet][google.spanner.v1.ResultSet] messages, with the
867
+ // status `OK`.
741
868
  //
742
869
  // Example 2:
743
870
  //
744
871
  // * Request: 5 DML statements. The third statement has a syntax error.
745
- // * Response: 2 [ResultSet][google.spanner.v1.ResultSet] messages, and a syntax error (`INVALID_ARGUMENT`)
746
- // status. The number of [ResultSet][google.spanner.v1.ResultSet] messages indicates that the third
747
- // statement failed, and the fourth and fifth statements were not executed.
872
+ // * Response: 2 [ResultSet][google.spanner.v1.ResultSet] messages, and a syntax
873
+ // error (`INVALID_ARGUMENT`)
874
+ // status. The number of [ResultSet][google.spanner.v1.ResultSet] messages
875
+ // indicates that the third statement failed, and the fourth and fifth
876
+ // statements were not executed.
748
877
  message ExecuteBatchDmlResponse {
749
- // One [ResultSet][google.spanner.v1.ResultSet] for each statement in the request that ran successfully,
750
- // in the same order as the statements in the request. Each [ResultSet][google.spanner.v1.ResultSet] does
751
- // not contain any rows. The [ResultSetStats][google.spanner.v1.ResultSetStats] in each [ResultSet][google.spanner.v1.ResultSet] contain
752
- // the number of rows modified by the statement.
878
+ // One [ResultSet][google.spanner.v1.ResultSet] for each statement in the
879
+ // request that ran successfully, in the same order as the statements in the
880
+ // request. Each [ResultSet][google.spanner.v1.ResultSet] does not contain any
881
+ // rows. The [ResultSetStats][google.spanner.v1.ResultSetStats] in each
882
+ // [ResultSet][google.spanner.v1.ResultSet] contain the number of rows
883
+ // modified by the statement.
753
884
  //
754
- // Only the first [ResultSet][google.spanner.v1.ResultSet] in the response contains valid
755
- // [ResultSetMetadata][google.spanner.v1.ResultSetMetadata].
885
+ // Only the first [ResultSet][google.spanner.v1.ResultSet] in the response
886
+ // contains valid [ResultSetMetadata][google.spanner.v1.ResultSetMetadata].
756
887
  repeated ResultSet result_sets = 1;
757
888
 
758
889
  // If all DML statements are executed successfully, the status is `OK`.
@@ -787,24 +918,23 @@ message PartitionQueryRequest {
787
918
  // Required. The session used to create the partitions.
788
919
  string session = 1 [
789
920
  (google.api.field_behavior) = REQUIRED,
790
- (google.api.resource_reference) = {
791
- type: "spanner.googleapis.com/Session"
792
- }
921
+ (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" }
793
922
  ];
794
923
 
795
924
  // Read only snapshot transactions are supported, read/write and single use
796
925
  // transactions are not.
797
926
  TransactionSelector transaction = 2;
798
927
 
799
- // Required. The query request to generate partitions for. The request will fail if
800
- // the query is not root partitionable. The query plan of a root
801
- // partitionable query has a single distributed union operator. A distributed
802
- // union operator conceptually divides one or more tables into multiple
803
- // splits, remotely evaluates a subquery independently on each split, and
804
- // then unions all results.
928
+ // Required. The query request to generate partitions for. The request will
929
+ // fail if the query is not root partitionable. For a query to be root
930
+ // partitionable, it needs to satisfy a few conditions. For example, the first
931
+ // operator in the query execution plan must be a distributed union operator.
932
+ // For more information about other conditions, see [Read data in
933
+ // parallel](https://cloud.google.com/spanner/docs/reads#read_data_in_parallel).
805
934
  //
806
- // This must not contain DML commands, such as INSERT, UPDATE, or
807
- // DELETE. Use [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] with a
935
+ // The query request must not contain DML commands, such as INSERT, UPDATE, or
936
+ // DELETE. Use
937
+ // [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] with a
808
938
  // PartitionedDml transaction for large, partition-friendly DML operations.
809
939
  string sql = 3 [(google.api.field_behavior) = REQUIRED];
810
940
 
@@ -824,7 +954,8 @@ message PartitionQueryRequest {
824
954
 
825
955
  // It is not always possible for Cloud Spanner to infer the right SQL type
826
956
  // from a JSON value. For example, values of type `BYTES` and values
827
- // of type `STRING` both appear in [params][google.spanner.v1.PartitionQueryRequest.params] as JSON strings.
957
+ // of type `STRING` both appear in
958
+ // [params][google.spanner.v1.PartitionQueryRequest.params] as JSON strings.
828
959
  //
829
960
  // In these cases, `param_types` can be used to specify the exact
830
961
  // SQL type for some or all of the SQL query parameters. See the
@@ -841,9 +972,7 @@ message PartitionReadRequest {
841
972
  // Required. The session used to create the partitions.
842
973
  string session = 1 [
843
974
  (google.api.field_behavior) = REQUIRED,
844
- (google.api.resource_reference) = {
845
- type: "spanner.googleapis.com/Session"
846
- }
975
+ (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" }
847
976
  ];
848
977
 
849
978
  // Read only snapshot transactions are supported, read/write and single use
@@ -853,18 +982,24 @@ message PartitionReadRequest {
853
982
  // Required. The name of the table in the database to be read.
854
983
  string table = 3 [(google.api.field_behavior) = REQUIRED];
855
984
 
856
- // If non-empty, the name of an index on [table][google.spanner.v1.PartitionReadRequest.table]. This index is
857
- // used instead of the table primary key when interpreting [key_set][google.spanner.v1.PartitionReadRequest.key_set]
858
- // and sorting result rows. See [key_set][google.spanner.v1.PartitionReadRequest.key_set] for further information.
985
+ // If non-empty, the name of an index on
986
+ // [table][google.spanner.v1.PartitionReadRequest.table]. This index is used
987
+ // instead of the table primary key when interpreting
988
+ // [key_set][google.spanner.v1.PartitionReadRequest.key_set] and sorting
989
+ // result rows. See [key_set][google.spanner.v1.PartitionReadRequest.key_set]
990
+ // for further information.
859
991
  string index = 4;
860
992
 
861
- // The columns of [table][google.spanner.v1.PartitionReadRequest.table] to be returned for each row matching
862
- // this request.
993
+ // The columns of [table][google.spanner.v1.PartitionReadRequest.table] to be
994
+ // returned for each row matching this request.
863
995
  repeated string columns = 5;
864
996
 
865
997
  // Required. `key_set` identifies the rows to be yielded. `key_set` names the
866
- // primary keys of the rows in [table][google.spanner.v1.PartitionReadRequest.table] to be yielded, unless [index][google.spanner.v1.PartitionReadRequest.index]
867
- // is present. If [index][google.spanner.v1.PartitionReadRequest.index] is present, then [key_set][google.spanner.v1.PartitionReadRequest.key_set] instead names
998
+ // primary keys of the rows in
999
+ // [table][google.spanner.v1.PartitionReadRequest.table] to be yielded, unless
1000
+ // [index][google.spanner.v1.PartitionReadRequest.index] is present. If
1001
+ // [index][google.spanner.v1.PartitionReadRequest.index] is present, then
1002
+ // [key_set][google.spanner.v1.PartitionReadRequest.key_set] instead names
868
1003
  // index keys in [index][google.spanner.v1.PartitionReadRequest.index].
869
1004
  //
870
1005
  // It is not an error for the `key_set` to name rows that do not
@@ -900,9 +1035,7 @@ message ReadRequest {
900
1035
  // Required. The session in which the read should be performed.
901
1036
  string session = 1 [
902
1037
  (google.api.field_behavior) = REQUIRED,
903
- (google.api.resource_reference) = {
904
- type: "spanner.googleapis.com/Session"
905
- }
1038
+ (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" }
906
1039
  ];
907
1040
 
908
1041
  // The transaction to use. If none is provided, the default is a
@@ -912,24 +1045,31 @@ message ReadRequest {
912
1045
  // Required. The name of the table in the database to be read.
913
1046
  string table = 3 [(google.api.field_behavior) = REQUIRED];
914
1047
 
915
- // If non-empty, the name of an index on [table][google.spanner.v1.ReadRequest.table]. This index is
916
- // used instead of the table primary key when interpreting [key_set][google.spanner.v1.ReadRequest.key_set]
917
- // and sorting result rows. See [key_set][google.spanner.v1.ReadRequest.key_set] for further information.
1048
+ // If non-empty, the name of an index on
1049
+ // [table][google.spanner.v1.ReadRequest.table]. This index is used instead of
1050
+ // the table primary key when interpreting
1051
+ // [key_set][google.spanner.v1.ReadRequest.key_set] and sorting result rows.
1052
+ // See [key_set][google.spanner.v1.ReadRequest.key_set] for further
1053
+ // information.
918
1054
  string index = 4;
919
1055
 
920
- // Required. The columns of [table][google.spanner.v1.ReadRequest.table] to be returned for each row matching
921
- // this request.
1056
+ // Required. The columns of [table][google.spanner.v1.ReadRequest.table] to be
1057
+ // returned for each row matching this request.
922
1058
  repeated string columns = 5 [(google.api.field_behavior) = REQUIRED];
923
1059
 
924
1060
  // Required. `key_set` identifies the rows to be yielded. `key_set` names the
925
- // primary keys of the rows in [table][google.spanner.v1.ReadRequest.table] to be yielded, unless [index][google.spanner.v1.ReadRequest.index]
926
- // is present. If [index][google.spanner.v1.ReadRequest.index] is present, then [key_set][google.spanner.v1.ReadRequest.key_set] instead names
927
- // index keys in [index][google.spanner.v1.ReadRequest.index].
1061
+ // primary keys of the rows in [table][google.spanner.v1.ReadRequest.table] to
1062
+ // be yielded, unless [index][google.spanner.v1.ReadRequest.index] is present.
1063
+ // If [index][google.spanner.v1.ReadRequest.index] is present, then
1064
+ // [key_set][google.spanner.v1.ReadRequest.key_set] instead names index keys
1065
+ // in [index][google.spanner.v1.ReadRequest.index].
928
1066
  //
929
- // If the [partition_token][google.spanner.v1.ReadRequest.partition_token] field is empty, rows are yielded
930
- // in table primary key order (if [index][google.spanner.v1.ReadRequest.index] is empty) or index key order
931
- // (if [index][google.spanner.v1.ReadRequest.index] is non-empty). If the [partition_token][google.spanner.v1.ReadRequest.partition_token] field is not
932
- // empty, rows will be yielded in an unspecified order.
1067
+ // If the [partition_token][google.spanner.v1.ReadRequest.partition_token]
1068
+ // field is empty, rows are yielded in table primary key order (if
1069
+ // [index][google.spanner.v1.ReadRequest.index] is empty) or index key order
1070
+ // (if [index][google.spanner.v1.ReadRequest.index] is non-empty). If the
1071
+ // [partition_token][google.spanner.v1.ReadRequest.partition_token] field is
1072
+ // not empty, rows will be yielded in an unspecified order.
933
1073
  //
934
1074
  // It is not an error for the `key_set` to name rows that do not
935
1075
  // exist in the database. Read yields nothing for nonexistent rows.
@@ -942,9 +1082,9 @@ message ReadRequest {
942
1082
 
943
1083
  // If this request is resuming a previously interrupted read,
944
1084
  // `resume_token` should be copied from the last
945
- // [PartialResultSet][google.spanner.v1.PartialResultSet] yielded before the interruption. Doing this
946
- // enables the new read to resume where the last read left off. The
947
- // rest of the request parameters must exactly match the request
1085
+ // [PartialResultSet][google.spanner.v1.PartialResultSet] yielded before the
1086
+ // interruption. Doing this enables the new read to resume where the last read
1087
+ // left off. The rest of the request parameters must exactly match the request
948
1088
  // that yielded this token.
949
1089
  bytes resume_token = 9;
950
1090
 
@@ -957,22 +1097,24 @@ message ReadRequest {
957
1097
  // Common options for this request.
958
1098
  RequestOptions request_options = 11;
959
1099
 
1100
+ // Directed read options for this request.
1101
+ DirectedReadOptions directed_read_options = 14;
1102
+
960
1103
  // If this is for a partitioned read and this field is set to `true`, the
961
- // request will be executed via Spanner independent compute resources.
1104
+ // request is executed with Spanner Data Boost independent compute resources.
962
1105
  //
963
1106
  // If the field is set to `true` but the request does not set
964
- // `partition_token`, the API will return an `INVALID_ARGUMENT` error.
1107
+ // `partition_token`, the API returns an `INVALID_ARGUMENT` error.
965
1108
  bool data_boost_enabled = 15;
966
1109
  }
967
1110
 
968
- // The request for [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction].
1111
+ // The request for
1112
+ // [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction].
969
1113
  message BeginTransactionRequest {
970
1114
  // Required. The session in which the transaction runs.
971
1115
  string session = 1 [
972
1116
  (google.api.field_behavior) = REQUIRED,
973
- (google.api.resource_reference) = {
974
- type: "spanner.googleapis.com/Session"
975
- }
1117
+ (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" }
976
1118
  ];
977
1119
 
978
1120
  // Required. Options for the new transaction.
@@ -991,9 +1133,7 @@ message CommitRequest {
991
1133
  // Required. The session in which the transaction to be committed is running.
992
1134
  string session = 1 [
993
1135
  (google.api.field_behavior) = REQUIRED,
994
- (google.api.resource_reference) = {
995
- type: "spanner.googleapis.com/Session"
996
- }
1136
+ (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" }
997
1137
  ];
998
1138
 
999
1139
  // Required. The transaction in which to commit.
@@ -1019,8 +1159,8 @@ message CommitRequest {
1019
1159
  repeated Mutation mutations = 4;
1020
1160
 
1021
1161
  // If `true`, then statistics related to the transaction will be included in
1022
- // the [CommitResponse][google.spanner.v1.CommitResponse.commit_stats]. Default value is
1023
- // `false`.
1162
+ // the [CommitResponse][google.spanner.v1.CommitResponse.commit_stats].
1163
+ // Default value is `false`.
1024
1164
  bool return_commit_stats = 5;
1025
1165
 
1026
1166
  // Common options for this request.
@@ -1032,11 +1172,47 @@ message RollbackRequest {
1032
1172
  // Required. The session in which the transaction to roll back is running.
1033
1173
  string session = 1 [
1034
1174
  (google.api.field_behavior) = REQUIRED,
1035
- (google.api.resource_reference) = {
1036
- type: "spanner.googleapis.com/Session"
1037
- }
1175
+ (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" }
1038
1176
  ];
1039
1177
 
1040
1178
  // Required. The transaction to roll back.
1041
1179
  bytes transaction_id = 2 [(google.api.field_behavior) = REQUIRED];
1042
1180
  }
1181
+
1182
+ // The request for [BatchWrite][google.spanner.v1.Spanner.BatchWrite].
1183
+ message BatchWriteRequest {
1184
+ // A group of mutations to be committed together. Related mutations should be
1185
+ // placed in a group. For example, two mutations inserting rows with the same
1186
+ // primary key prefix in both parent and child tables are related.
1187
+ message MutationGroup {
1188
+ // Required. The mutations in this group.
1189
+ repeated Mutation mutations = 1 [(google.api.field_behavior) = REQUIRED];
1190
+ }
1191
+
1192
+ // Required. The session in which the batch request is to be run.
1193
+ string session = 1 [
1194
+ (google.api.field_behavior) = REQUIRED,
1195
+ (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" }
1196
+ ];
1197
+
1198
+ // Common options for this request.
1199
+ RequestOptions request_options = 3;
1200
+
1201
+ // Required. The groups of mutations to be applied.
1202
+ repeated MutationGroup mutation_groups = 4
1203
+ [(google.api.field_behavior) = REQUIRED];
1204
+ }
1205
+
1206
+ // The result of applying a batch of mutations.
1207
+ message BatchWriteResponse {
1208
+ // The mutation groups applied in this batch. The values index into the
1209
+ // `mutation_groups` field in the corresponding `BatchWriteRequest`.
1210
+ repeated int32 indexes = 1;
1211
+
1212
+ // An `OK` status indicates success. Any other status indicates a failure.
1213
+ google.rpc.Status status = 2;
1214
+
1215
+ // The commit timestamp of the transaction that applied this batch.
1216
+ // Present if `status` is `OK`, absent otherwise.
1217
+ google.protobuf.Timestamp commit_timestamp = 3;
1218
+ }