@google-cloud/bigquery-storage-api 0.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.
Files changed (29) hide show
  1. package/README.md +111 -0
  2. package/build/protos/google/cloud/bigquery/storage/v1/annotations.proto +28 -0
  3. package/build/protos/google/cloud/bigquery/storage/v1/arrow.proto +89 -0
  4. package/build/protos/google/cloud/bigquery/storage/v1/avro.proto +81 -0
  5. package/build/protos/google/cloud/bigquery/storage/v1/protobuf.proto +48 -0
  6. package/build/protos/google/cloud/bigquery/storage/v1/storage.proto +786 -0
  7. package/build/protos/google/cloud/bigquery/storage/v1/stream.proto +335 -0
  8. package/build/protos/google/cloud/bigquery/storage/v1/table.proto +200 -0
  9. package/build/protos/protos.d.ts +12699 -0
  10. package/build/protos/protos.js +1 -0
  11. package/build/protos/protos.json +1 -0
  12. package/build/src/index.d.ts +14 -0
  13. package/build/src/index.js +30 -0
  14. package/build/src/index.js.map +1 -0
  15. package/build/src/v1/big_query_read_client.d.ts +424 -0
  16. package/build/src/v1/big_query_read_client.js +689 -0
  17. package/build/src/v1/big_query_read_client.js.map +1 -0
  18. package/build/src/v1/big_query_read_client_config.json +44 -0
  19. package/build/src/v1/big_query_read_proto_list.json +9 -0
  20. package/build/src/v1/big_query_write_client.d.ts +486 -0
  21. package/build/src/v1/big_query_write_client.js +835 -0
  22. package/build/src/v1/big_query_write_client.js.map +1 -0
  23. package/build/src/v1/big_query_write_client_config.json +73 -0
  24. package/build/src/v1/big_query_write_proto_list.json +9 -0
  25. package/build/src/v1/gapic_metadata.json +117 -0
  26. package/build/src/v1/index.d.ts +2 -0
  27. package/build/src/v1/index.js +25 -0
  28. package/build/src/v1/index.js.map +1 -0
  29. package/package.json +66 -0
@@ -0,0 +1,786 @@
1
+ // Copyright 2025 Google LLC
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ syntax = "proto3";
16
+
17
+ package google.cloud.bigquery.storage.v1;
18
+
19
+ import "google/api/annotations.proto";
20
+ import "google/api/client.proto";
21
+ import "google/api/field_behavior.proto";
22
+ import "google/api/resource.proto";
23
+ import "google/cloud/bigquery/storage/v1/arrow.proto";
24
+ import "google/cloud/bigquery/storage/v1/avro.proto";
25
+ import "google/cloud/bigquery/storage/v1/protobuf.proto";
26
+ import "google/cloud/bigquery/storage/v1/stream.proto";
27
+ import "google/cloud/bigquery/storage/v1/table.proto";
28
+ import "google/protobuf/timestamp.proto";
29
+ import "google/protobuf/wrappers.proto";
30
+ import "google/rpc/status.proto";
31
+
32
+ option csharp_namespace = "Google.Cloud.BigQuery.Storage.V1";
33
+ option go_package = "cloud.google.com/go/bigquery/storage/apiv1/storagepb;storagepb";
34
+ option java_multiple_files = true;
35
+ option java_outer_classname = "StorageProto";
36
+ option java_package = "com.google.cloud.bigquery.storage.v1";
37
+ option php_namespace = "Google\\Cloud\\BigQuery\\Storage\\V1";
38
+ option (google.api.resource_definition) = {
39
+ type: "bigquery.googleapis.com/Table"
40
+ pattern: "projects/{project}/datasets/{dataset}/tables/{table}"
41
+ };
42
+
43
+ // BigQuery Read API.
44
+ //
45
+ // The Read API can be used to read data from BigQuery.
46
+ service BigQueryRead {
47
+ option (google.api.default_host) = "bigquerystorage.googleapis.com";
48
+ option (google.api.oauth_scopes) =
49
+ "https://www.googleapis.com/auth/bigquery,"
50
+ "https://www.googleapis.com/auth/cloud-platform";
51
+
52
+ // Creates a new read session. A read session divides the contents of a
53
+ // BigQuery table into one or more streams, which can then be used to read
54
+ // data from the table. The read session also specifies properties of the
55
+ // data to be read, such as a list of columns or a push-down filter describing
56
+ // the rows to be returned.
57
+ //
58
+ // A particular row can be read by at most one stream. When the caller has
59
+ // reached the end of each stream in the session, then all the data in the
60
+ // table has been read.
61
+ //
62
+ // Data is assigned to each stream such that roughly the same number of
63
+ // rows can be read from each stream. Because the server-side unit for
64
+ // assigning data is collections of rows, the API does not guarantee that
65
+ // each stream will return the same number or rows. Additionally, the
66
+ // limits are enforced based on the number of pre-filtered rows, so some
67
+ // filters can lead to lopsided assignments.
68
+ //
69
+ // Read sessions automatically expire 6 hours after they are created and do
70
+ // not require manual clean-up by the caller.
71
+ rpc CreateReadSession(CreateReadSessionRequest) returns (ReadSession) {
72
+ option (google.api.http) = {
73
+ post: "/v1/{read_session.table=projects/*/datasets/*/tables/*}"
74
+ body: "*"
75
+ };
76
+ option (google.api.method_signature) =
77
+ "parent,read_session,max_stream_count";
78
+ }
79
+
80
+ // Reads rows from the stream in the format prescribed by the ReadSession.
81
+ // Each response contains one or more table rows, up to a maximum of 128 MB
82
+ // per response; read requests which attempt to read individual rows larger
83
+ // than 128 MB will fail.
84
+ //
85
+ // Each request also returns a set of stream statistics reflecting the current
86
+ // state of the stream.
87
+ rpc ReadRows(ReadRowsRequest) returns (stream ReadRowsResponse) {
88
+ option (google.api.http) = {
89
+ get: "/v1/{read_stream=projects/*/locations/*/sessions/*/streams/*}"
90
+ };
91
+ option (google.api.method_signature) = "read_stream,offset";
92
+ }
93
+
94
+ // Splits a given `ReadStream` into two `ReadStream` objects. These
95
+ // `ReadStream` objects are referred to as the primary and the residual
96
+ // streams of the split. The original `ReadStream` can still be read from in
97
+ // the same manner as before. Both of the returned `ReadStream` objects can
98
+ // also be read from, and the rows returned by both child streams will be
99
+ // the same as the rows read from the original stream.
100
+ //
101
+ // Moreover, the two child streams will be allocated back-to-back in the
102
+ // original `ReadStream`. Concretely, it is guaranteed that for streams
103
+ // original, primary, and residual, that original[0-j] = primary[0-j] and
104
+ // original[j-n] = residual[0-m] once the streams have been read to
105
+ // completion.
106
+ rpc SplitReadStream(SplitReadStreamRequest)
107
+ returns (SplitReadStreamResponse) {
108
+ option (google.api.http) = {
109
+ get: "/v1/{name=projects/*/locations/*/sessions/*/streams/*}"
110
+ };
111
+ }
112
+ }
113
+
114
+ // BigQuery Write API.
115
+ //
116
+ // The Write API can be used to write data to BigQuery.
117
+ //
118
+ // For supplementary information about the Write API, see:
119
+ // https://cloud.google.com/bigquery/docs/write-api
120
+ service BigQueryWrite {
121
+ option (google.api.default_host) = "bigquerystorage.googleapis.com";
122
+ option (google.api.oauth_scopes) =
123
+ "https://www.googleapis.com/auth/bigquery,"
124
+ "https://www.googleapis.com/auth/bigquery.insertdata,"
125
+ "https://www.googleapis.com/auth/cloud-platform";
126
+
127
+ // Creates a write stream to the given table.
128
+ // Additionally, every table has a special stream named '_default'
129
+ // to which data can be written. This stream doesn't need to be created using
130
+ // CreateWriteStream. It is a stream that can be used simultaneously by any
131
+ // number of clients. Data written to this stream is considered committed as
132
+ // soon as an acknowledgement is received.
133
+ rpc CreateWriteStream(CreateWriteStreamRequest) returns (WriteStream) {
134
+ option (google.api.http) = {
135
+ post: "/v1/{parent=projects/*/datasets/*/tables/*}"
136
+ body: "write_stream"
137
+ };
138
+ option (google.api.method_signature) = "parent,write_stream";
139
+ }
140
+
141
+ // Appends data to the given stream.
142
+ //
143
+ // If `offset` is specified, the `offset` is checked against the end of
144
+ // stream. The server returns `OUT_OF_RANGE` in `AppendRowsResponse` if an
145
+ // attempt is made to append to an offset beyond the current end of the stream
146
+ // or `ALREADY_EXISTS` if user provides an `offset` that has already been
147
+ // written to. User can retry with adjusted offset within the same RPC
148
+ // connection. If `offset` is not specified, append happens at the end of the
149
+ // stream.
150
+ //
151
+ // The response contains an optional offset at which the append
152
+ // happened. No offset information will be returned for appends to a
153
+ // default stream.
154
+ //
155
+ // Responses are received in the same order in which requests are sent.
156
+ // There will be one response for each successful inserted request. Responses
157
+ // may optionally embed error information if the originating AppendRequest was
158
+ // not successfully processed.
159
+ //
160
+ // The specifics of when successfully appended data is made visible to the
161
+ // table are governed by the type of stream:
162
+ //
163
+ // * For COMMITTED streams (which includes the default stream), data is
164
+ // visible immediately upon successful append.
165
+ //
166
+ // * For BUFFERED streams, data is made visible via a subsequent `FlushRows`
167
+ // rpc which advances a cursor to a newer offset in the stream.
168
+ //
169
+ // * For PENDING streams, data is not made visible until the stream itself is
170
+ // finalized (via the `FinalizeWriteStream` rpc), and the stream is explicitly
171
+ // committed via the `BatchCommitWriteStreams` rpc.
172
+ rpc AppendRows(stream AppendRowsRequest) returns (stream AppendRowsResponse) {
173
+ option (google.api.http) = {
174
+ post: "/v1/{write_stream=projects/*/datasets/*/tables/*/streams/*}"
175
+ body: "*"
176
+ };
177
+ option (google.api.method_signature) = "write_stream";
178
+ }
179
+
180
+ // Gets information about a write stream.
181
+ rpc GetWriteStream(GetWriteStreamRequest) returns (WriteStream) {
182
+ option (google.api.http) = {
183
+ post: "/v1/{name=projects/*/datasets/*/tables/*/streams/*}"
184
+ body: "*"
185
+ };
186
+ option (google.api.method_signature) = "name";
187
+ }
188
+
189
+ // Finalize a write stream so that no new data can be appended to the
190
+ // stream. Finalize is not supported on the '_default' stream.
191
+ rpc FinalizeWriteStream(FinalizeWriteStreamRequest)
192
+ returns (FinalizeWriteStreamResponse) {
193
+ option (google.api.http) = {
194
+ post: "/v1/{name=projects/*/datasets/*/tables/*/streams/*}"
195
+ body: "*"
196
+ };
197
+ option (google.api.method_signature) = "name";
198
+ }
199
+
200
+ // Atomically commits a group of `PENDING` streams that belong to the same
201
+ // `parent` table.
202
+ //
203
+ // Streams must be finalized before commit and cannot be committed multiple
204
+ // times. Once a stream is committed, data in the stream becomes available
205
+ // for read operations.
206
+ rpc BatchCommitWriteStreams(BatchCommitWriteStreamsRequest)
207
+ returns (BatchCommitWriteStreamsResponse) {
208
+ option (google.api.http) = {
209
+ get: "/v1/{parent=projects/*/datasets/*/tables/*}"
210
+ };
211
+ option (google.api.method_signature) = "parent";
212
+ }
213
+
214
+ // Flushes rows to a BUFFERED stream.
215
+ //
216
+ // If users are appending rows to BUFFERED stream, flush operation is
217
+ // required in order for the rows to become available for reading. A
218
+ // Flush operation flushes up to any previously flushed offset in a BUFFERED
219
+ // stream, to the offset specified in the request.
220
+ //
221
+ // Flush is not supported on the _default stream, since it is not BUFFERED.
222
+ rpc FlushRows(FlushRowsRequest) returns (FlushRowsResponse) {
223
+ option (google.api.http) = {
224
+ post: "/v1/{write_stream=projects/*/datasets/*/tables/*/streams/*}"
225
+ body: "*"
226
+ };
227
+ option (google.api.method_signature) = "write_stream";
228
+ }
229
+ }
230
+
231
+ // Request message for `CreateReadSession`.
232
+ message CreateReadSessionRequest {
233
+ // Required. The request project that owns the session, in the form of
234
+ // `projects/{project_id}`.
235
+ string parent = 1 [
236
+ (google.api.field_behavior) = REQUIRED,
237
+ (google.api.resource_reference) = {
238
+ type: "cloudresourcemanager.googleapis.com/Project"
239
+ }
240
+ ];
241
+
242
+ // Required. Session to be created.
243
+ ReadSession read_session = 2 [(google.api.field_behavior) = REQUIRED];
244
+
245
+ // Max initial number of streams. If unset or zero, the server will
246
+ // provide a value of streams so as to produce reasonable throughput. Must be
247
+ // non-negative. The number of streams may be lower than the requested number,
248
+ // depending on the amount parallelism that is reasonable for the table.
249
+ // There is a default system max limit of 1,000.
250
+ //
251
+ // This must be greater than or equal to preferred_min_stream_count.
252
+ // Typically, clients should either leave this unset to let the system to
253
+ // determine an upper bound OR set this a size for the maximum "units of work"
254
+ // it can gracefully handle.
255
+ int32 max_stream_count = 3;
256
+
257
+ // The minimum preferred stream count. This parameter can be used to inform
258
+ // the service that there is a desired lower bound on the number of streams.
259
+ // This is typically a target parallelism of the client (e.g. a Spark
260
+ // cluster with N-workers would set this to a low multiple of N to ensure
261
+ // good cluster utilization).
262
+ //
263
+ // The system will make a best effort to provide at least this number of
264
+ // streams, but in some cases might provide less.
265
+ int32 preferred_min_stream_count = 4;
266
+ }
267
+
268
+ // Request message for `ReadRows`.
269
+ message ReadRowsRequest {
270
+ // Required. Stream to read rows from.
271
+ string read_stream = 1 [
272
+ (google.api.field_behavior) = REQUIRED,
273
+ (google.api.resource_reference) = {
274
+ type: "bigquerystorage.googleapis.com/ReadStream"
275
+ }
276
+ ];
277
+
278
+ // The offset requested must be less than the last row read from Read.
279
+ // Requesting a larger offset is undefined. If not specified, start reading
280
+ // from offset zero.
281
+ int64 offset = 2;
282
+ }
283
+
284
+ // Information on if the current connection is being throttled.
285
+ message ThrottleState {
286
+ // How much this connection is being throttled. Zero means no throttling,
287
+ // 100 means fully throttled.
288
+ int32 throttle_percent = 1;
289
+ }
290
+
291
+ // Estimated stream statistics for a given read Stream.
292
+ message StreamStats {
293
+ message Progress {
294
+ // The fraction of rows assigned to the stream that have been processed by
295
+ // the server so far, not including the rows in the current response
296
+ // message.
297
+ //
298
+ // This value, along with `at_response_end`, can be used to interpolate
299
+ // the progress made as the rows in the message are being processed using
300
+ // the following formula: `at_response_start + (at_response_end -
301
+ // at_response_start) * rows_processed_from_response / rows_in_response`.
302
+ //
303
+ // Note that if a filter is provided, the `at_response_end` value of the
304
+ // previous response may not necessarily be equal to the
305
+ // `at_response_start` value of the current response.
306
+ double at_response_start = 1;
307
+
308
+ // Similar to `at_response_start`, except that this value includes the
309
+ // rows in the current response.
310
+ double at_response_end = 2;
311
+ }
312
+
313
+ // Represents the progress of the current stream.
314
+ Progress progress = 2;
315
+ }
316
+
317
+ // Response from calling `ReadRows` may include row data, progress and
318
+ // throttling information.
319
+ message ReadRowsResponse {
320
+ // Row data is returned in format specified during session creation.
321
+ oneof rows {
322
+ // Serialized row data in AVRO format.
323
+ AvroRows avro_rows = 3;
324
+
325
+ // Serialized row data in Arrow RecordBatch format.
326
+ ArrowRecordBatch arrow_record_batch = 4;
327
+ }
328
+
329
+ // Number of serialized rows in the rows block.
330
+ int64 row_count = 6;
331
+
332
+ // Statistics for the stream.
333
+ StreamStats stats = 2;
334
+
335
+ // Throttling state. If unset, the latest response still describes
336
+ // the current throttling status.
337
+ ThrottleState throttle_state = 5;
338
+
339
+ // The schema for the read. If read_options.selected_fields is set, the
340
+ // schema may be different from the table schema as it will only contain
341
+ // the selected fields. This schema is equivalent to the one returned by
342
+ // CreateSession. This field is only populated in the first ReadRowsResponse
343
+ // RPC.
344
+ oneof schema {
345
+ // Output only. Avro schema.
346
+ AvroSchema avro_schema = 7 [(google.api.field_behavior) = OUTPUT_ONLY];
347
+
348
+ // Output only. Arrow schema.
349
+ ArrowSchema arrow_schema = 8 [(google.api.field_behavior) = OUTPUT_ONLY];
350
+ }
351
+
352
+ // Optional. If the row data in this ReadRowsResponse is compressed, then
353
+ // uncompressed byte size is the original size of the uncompressed row data.
354
+ // If it is set to a value greater than 0, then decompress into a buffer of
355
+ // size uncompressed_byte_size using the compression codec that was requested
356
+ // during session creation time and which is specified in
357
+ // TableReadOptions.response_compression_codec in ReadSession.
358
+ // This value is not set if no response_compression_codec was not requested
359
+ // and it is -1 if the requested compression would not have reduced the size
360
+ // of this ReadRowsResponse's row data. This attempts to match Apache Arrow's
361
+ // behavior described here https://github.com/apache/arrow/issues/15102 where
362
+ // the uncompressed length may be set to -1 to indicate that the data that
363
+ // follows is not compressed, which can be useful for cases where compression
364
+ // does not yield appreciable savings. When uncompressed_byte_size is not
365
+ // greater than 0, the client should skip decompression.
366
+ optional int64 uncompressed_byte_size = 9
367
+ [(google.api.field_behavior) = OPTIONAL];
368
+ }
369
+
370
+ // Request message for `SplitReadStream`.
371
+ message SplitReadStreamRequest {
372
+ // Required. Name of the stream to split.
373
+ string name = 1 [
374
+ (google.api.field_behavior) = REQUIRED,
375
+ (google.api.resource_reference) = {
376
+ type: "bigquerystorage.googleapis.com/ReadStream"
377
+ }
378
+ ];
379
+
380
+ // A value in the range (0.0, 1.0) that specifies the fractional point at
381
+ // which the original stream should be split. The actual split point is
382
+ // evaluated on pre-filtered rows, so if a filter is provided, then there is
383
+ // no guarantee that the division of the rows between the new child streams
384
+ // will be proportional to this fractional value. Additionally, because the
385
+ // server-side unit for assigning data is collections of rows, this fraction
386
+ // will always map to a data storage boundary on the server side.
387
+ double fraction = 2;
388
+ }
389
+
390
+ // Response message for `SplitReadStream`.
391
+ message SplitReadStreamResponse {
392
+ // Primary stream, which contains the beginning portion of
393
+ // |original_stream|. An empty value indicates that the original stream can no
394
+ // longer be split.
395
+ ReadStream primary_stream = 1;
396
+
397
+ // Remainder stream, which contains the tail of |original_stream|. An empty
398
+ // value indicates that the original stream can no longer be split.
399
+ ReadStream remainder_stream = 2;
400
+ }
401
+
402
+ // Request message for `CreateWriteStream`.
403
+ message CreateWriteStreamRequest {
404
+ // Required. Reference to the table to which the stream belongs, in the format
405
+ // of `projects/{project}/datasets/{dataset}/tables/{table}`.
406
+ string parent = 1 [
407
+ (google.api.field_behavior) = REQUIRED,
408
+ (google.api.resource_reference) = { type: "bigquery.googleapis.com/Table" }
409
+ ];
410
+
411
+ // Required. Stream to be created.
412
+ WriteStream write_stream = 2 [(google.api.field_behavior) = REQUIRED];
413
+ }
414
+
415
+ // Request message for `AppendRows`.
416
+ //
417
+ // Because AppendRows is a bidirectional streaming RPC, certain parts of the
418
+ // AppendRowsRequest need only be specified for the first request before
419
+ // switching table destinations. You can also switch table destinations within
420
+ // the same connection for the default stream.
421
+ //
422
+ // The size of a single AppendRowsRequest must be less than 10 MB in size.
423
+ // Requests larger than this return an error, typically `INVALID_ARGUMENT`.
424
+ message AppendRowsRequest {
425
+ // Arrow schema and data.
426
+ message ArrowData {
427
+ // Optional. Arrow Schema used to serialize the data.
428
+ ArrowSchema writer_schema = 1;
429
+
430
+ // Required. Serialized row data in Arrow format.
431
+ ArrowRecordBatch rows = 2;
432
+ }
433
+
434
+ // ProtoData contains the data rows and schema when constructing append
435
+ // requests.
436
+ message ProtoData {
437
+ // Optional. The protocol buffer schema used to serialize the data. Provide
438
+ // this value whenever:
439
+ //
440
+ // * You send the first request of an RPC connection.
441
+ //
442
+ // * You change the input schema.
443
+ //
444
+ // * You specify a new destination table.
445
+ ProtoSchema writer_schema = 1;
446
+
447
+ // Required. Serialized row data in protobuf message format.
448
+ // Currently, the backend expects the serialized rows to adhere to
449
+ // proto2 semantics when appending rows, particularly with respect to
450
+ // how default values are encoded.
451
+ ProtoRows rows = 2;
452
+ }
453
+
454
+ // An enum to indicate how to interpret missing values of fields that are
455
+ // present in user schema but missing in rows. A missing value can represent a
456
+ // NULL or a column default value defined in BigQuery table schema.
457
+ enum MissingValueInterpretation {
458
+ // Invalid missing value interpretation. Requests with this value will be
459
+ // rejected.
460
+ MISSING_VALUE_INTERPRETATION_UNSPECIFIED = 0;
461
+
462
+ // Missing value is interpreted as NULL.
463
+ NULL_VALUE = 1;
464
+
465
+ // Missing value is interpreted as column default value if declared in the
466
+ // table schema, NULL otherwise.
467
+ DEFAULT_VALUE = 2;
468
+ }
469
+
470
+ // Required. The write_stream identifies the append operation. It must be
471
+ // provided in the following scenarios:
472
+ //
473
+ // * In the first request to an AppendRows connection.
474
+ //
475
+ // * In all subsequent requests to an AppendRows connection, if you use the
476
+ // same connection to write to multiple tables or change the input schema for
477
+ // default streams.
478
+ //
479
+ // For explicitly created write streams, the format is:
480
+ //
481
+ // * `projects/{project}/datasets/{dataset}/tables/{table}/streams/{id}`
482
+ //
483
+ // For the special default stream, the format is:
484
+ //
485
+ // * `projects/{project}/datasets/{dataset}/tables/{table}/streams/_default`.
486
+ //
487
+ // An example of a possible sequence of requests with write_stream fields
488
+ // within a single connection:
489
+ //
490
+ // * r1: {write_stream: stream_name_1}
491
+ //
492
+ // * r2: {write_stream: /*omit*/}
493
+ //
494
+ // * r3: {write_stream: /*omit*/}
495
+ //
496
+ // * r4: {write_stream: stream_name_2}
497
+ //
498
+ // * r5: {write_stream: stream_name_2}
499
+ //
500
+ // The destination changed in request_4, so the write_stream field must be
501
+ // populated in all subsequent requests in this stream.
502
+ string write_stream = 1 [
503
+ (google.api.field_behavior) = REQUIRED,
504
+ (google.api.resource_reference) = {
505
+ type: "bigquerystorage.googleapis.com/WriteStream"
506
+ }
507
+ ];
508
+
509
+ // If present, the write is only performed if the next append offset is same
510
+ // as the provided value. If not present, the write is performed at the
511
+ // current end of stream. Specifying a value for this field is not allowed
512
+ // when calling AppendRows for the '_default' stream.
513
+ google.protobuf.Int64Value offset = 2;
514
+
515
+ // Input rows. The `writer_schema` field must be specified at the initial
516
+ // request and currently, it will be ignored if specified in following
517
+ // requests. Following requests must have data in the same format as the
518
+ // initial request.
519
+ oneof rows {
520
+ // Rows in proto format.
521
+ ProtoData proto_rows = 4;
522
+
523
+ // Rows in arrow format.
524
+ ArrowData arrow_rows = 5;
525
+ }
526
+
527
+ // Id set by client to annotate its identity. Only initial request setting is
528
+ // respected.
529
+ string trace_id = 6;
530
+
531
+ // A map to indicate how to interpret missing value for some fields. Missing
532
+ // values are fields present in user schema but missing in rows. The key is
533
+ // the field name. The value is the interpretation of missing values for the
534
+ // field.
535
+ //
536
+ // For example, a map {'foo': NULL_VALUE, 'bar': DEFAULT_VALUE} means all
537
+ // missing values in field foo are interpreted as NULL, all missing values in
538
+ // field bar are interpreted as the default value of field bar in table
539
+ // schema.
540
+ //
541
+ // If a field is not in this map and has missing values, the missing values
542
+ // in this field are interpreted as NULL.
543
+ //
544
+ // This field only applies to the current request, it won't affect other
545
+ // requests on the connection.
546
+ //
547
+ // Currently, field name can only be top-level column name, can't be a struct
548
+ // field path like 'foo.bar'.
549
+ map<string, MissingValueInterpretation> missing_value_interpretations = 7;
550
+
551
+ // Optional. Default missing value interpretation for all columns in the
552
+ // table. When a value is specified on an `AppendRowsRequest`, it is applied
553
+ // to all requests from that point forward, until a subsequent
554
+ // `AppendRowsRequest` sets it to a different value.
555
+ // `missing_value_interpretation` can override
556
+ // `default_missing_value_interpretation`. For example, if you want to write
557
+ // `NULL` instead of using default values for some columns, you can set
558
+ // `default_missing_value_interpretation` to `DEFAULT_VALUE` and at the same
559
+ // time, set `missing_value_interpretations` to `NULL_VALUE` on those columns.
560
+ MissingValueInterpretation default_missing_value_interpretation = 8
561
+ [(google.api.field_behavior) = OPTIONAL];
562
+ }
563
+
564
+ // Response message for `AppendRows`.
565
+ message AppendRowsResponse {
566
+ // AppendResult is returned for successful append requests.
567
+ message AppendResult {
568
+ // The row offset at which the last append occurred. The offset will not be
569
+ // set if appending using default streams.
570
+ google.protobuf.Int64Value offset = 1;
571
+ }
572
+
573
+ oneof response {
574
+ // Result if the append is successful.
575
+ AppendResult append_result = 1;
576
+
577
+ // Error returned when problems were encountered. If present,
578
+ // it indicates rows were not accepted into the system.
579
+ // Users can retry or continue with other append requests within the
580
+ // same connection.
581
+ //
582
+ // Additional information about error signalling:
583
+ //
584
+ // ALREADY_EXISTS: Happens when an append specified an offset, and the
585
+ // backend already has received data at this offset. Typically encountered
586
+ // in retry scenarios, and can be ignored.
587
+ //
588
+ // OUT_OF_RANGE: Returned when the specified offset in the stream is beyond
589
+ // the current end of the stream.
590
+ //
591
+ // INVALID_ARGUMENT: Indicates a malformed request or data.
592
+ //
593
+ // ABORTED: Request processing is aborted because of prior failures. The
594
+ // request can be retried if previous failure is addressed.
595
+ //
596
+ // INTERNAL: Indicates server side error(s) that can be retried.
597
+ google.rpc.Status error = 2;
598
+ }
599
+
600
+ // If backend detects a schema update, pass it to user so that user can
601
+ // use it to input new type of message. It will be empty when no schema
602
+ // updates have occurred.
603
+ TableSchema updated_schema = 3;
604
+
605
+ // If a request failed due to corrupted rows, no rows in the batch will be
606
+ // appended. The API will return row level error info, so that the caller can
607
+ // remove the bad rows and retry the request.
608
+ repeated RowError row_errors = 4;
609
+
610
+ // The target of the append operation. Matches the write_stream in the
611
+ // corresponding request.
612
+ string write_stream = 5;
613
+ }
614
+
615
+ // Request message for `GetWriteStreamRequest`.
616
+ message GetWriteStreamRequest {
617
+ // Required. Name of the stream to get, in the form of
618
+ // `projects/{project}/datasets/{dataset}/tables/{table}/streams/{stream}`.
619
+ string name = 1 [
620
+ (google.api.field_behavior) = REQUIRED,
621
+ (google.api.resource_reference) = {
622
+ type: "bigquerystorage.googleapis.com/WriteStream"
623
+ }
624
+ ];
625
+
626
+ // Indicates whether to get full or partial view of the WriteStream. If
627
+ // not set, view returned will be basic.
628
+ WriteStreamView view = 3;
629
+ }
630
+
631
+ // Request message for `BatchCommitWriteStreams`.
632
+ message BatchCommitWriteStreamsRequest {
633
+ // Required. Parent table that all the streams should belong to, in the form
634
+ // of `projects/{project}/datasets/{dataset}/tables/{table}`.
635
+ string parent = 1 [
636
+ (google.api.field_behavior) = REQUIRED,
637
+ (google.api.resource_reference) = { type: "bigquery.googleapis.com/Table" }
638
+ ];
639
+
640
+ // Required. The group of streams that will be committed atomically.
641
+ repeated string write_streams = 2 [(google.api.field_behavior) = REQUIRED];
642
+ }
643
+
644
+ // Response message for `BatchCommitWriteStreams`.
645
+ message BatchCommitWriteStreamsResponse {
646
+ // The time at which streams were committed in microseconds granularity.
647
+ // This field will only exist when there are no stream errors.
648
+ // **Note** if this field is not set, it means the commit was not successful.
649
+ google.protobuf.Timestamp commit_time = 1;
650
+
651
+ // Stream level error if commit failed. Only streams with error will be in
652
+ // the list.
653
+ // If empty, there is no error and all streams are committed successfully.
654
+ // If non empty, certain streams have errors and ZERO stream is committed due
655
+ // to atomicity guarantee.
656
+ repeated StorageError stream_errors = 2;
657
+ }
658
+
659
+ // Request message for invoking `FinalizeWriteStream`.
660
+ message FinalizeWriteStreamRequest {
661
+ // Required. Name of the stream to finalize, in the form of
662
+ // `projects/{project}/datasets/{dataset}/tables/{table}/streams/{stream}`.
663
+ string name = 1 [
664
+ (google.api.field_behavior) = REQUIRED,
665
+ (google.api.resource_reference) = {
666
+ type: "bigquerystorage.googleapis.com/WriteStream"
667
+ }
668
+ ];
669
+ }
670
+
671
+ // Response message for `FinalizeWriteStream`.
672
+ message FinalizeWriteStreamResponse {
673
+ // Number of rows in the finalized stream.
674
+ int64 row_count = 1;
675
+ }
676
+
677
+ // Request message for `FlushRows`.
678
+ message FlushRowsRequest {
679
+ // Required. The stream that is the target of the flush operation.
680
+ string write_stream = 1 [
681
+ (google.api.field_behavior) = REQUIRED,
682
+ (google.api.resource_reference) = {
683
+ type: "bigquerystorage.googleapis.com/WriteStream"
684
+ }
685
+ ];
686
+
687
+ // Ending offset of the flush operation. Rows before this offset(including
688
+ // this offset) will be flushed.
689
+ google.protobuf.Int64Value offset = 2;
690
+ }
691
+
692
+ // Respond message for `FlushRows`.
693
+ message FlushRowsResponse {
694
+ // The rows before this offset (including this offset) are flushed.
695
+ int64 offset = 1;
696
+ }
697
+
698
+ // Structured custom BigQuery Storage error message. The error can be attached
699
+ // as error details in the returned rpc Status. In particular, the use of error
700
+ // codes allows more structured error handling, and reduces the need to evaluate
701
+ // unstructured error text strings.
702
+ message StorageError {
703
+ // Error code for `StorageError`.
704
+ enum StorageErrorCode {
705
+ // Default error.
706
+ STORAGE_ERROR_CODE_UNSPECIFIED = 0;
707
+
708
+ // Table is not found in the system.
709
+ TABLE_NOT_FOUND = 1;
710
+
711
+ // Stream is already committed.
712
+ STREAM_ALREADY_COMMITTED = 2;
713
+
714
+ // Stream is not found.
715
+ STREAM_NOT_FOUND = 3;
716
+
717
+ // Invalid Stream type.
718
+ // For example, you try to commit a stream that is not pending.
719
+ INVALID_STREAM_TYPE = 4;
720
+
721
+ // Invalid Stream state.
722
+ // For example, you try to commit a stream that is not finalized or is
723
+ // garbaged.
724
+ INVALID_STREAM_STATE = 5;
725
+
726
+ // Stream is finalized.
727
+ STREAM_FINALIZED = 6;
728
+
729
+ // There is a schema mismatch and it is caused by user schema has extra
730
+ // field than bigquery schema.
731
+ SCHEMA_MISMATCH_EXTRA_FIELDS = 7;
732
+
733
+ // Offset already exists.
734
+ OFFSET_ALREADY_EXISTS = 8;
735
+
736
+ // Offset out of range.
737
+ OFFSET_OUT_OF_RANGE = 9;
738
+
739
+ // Customer-managed encryption key (CMEK) not provided for CMEK-enabled
740
+ // data.
741
+ CMEK_NOT_PROVIDED = 10;
742
+
743
+ // Customer-managed encryption key (CMEK) was incorrectly provided.
744
+ INVALID_CMEK_PROVIDED = 11;
745
+
746
+ // There is an encryption error while using customer-managed encryption key.
747
+ CMEK_ENCRYPTION_ERROR = 12;
748
+
749
+ // Key Management Service (KMS) service returned an error, which can be
750
+ // retried.
751
+ KMS_SERVICE_ERROR = 13;
752
+
753
+ // Permission denied while using customer-managed encryption key.
754
+ KMS_PERMISSION_DENIED = 14;
755
+ }
756
+
757
+ // BigQuery Storage specific error code.
758
+ StorageErrorCode code = 1;
759
+
760
+ // Name of the failed entity.
761
+ string entity = 2;
762
+
763
+ // Message that describes the error.
764
+ string error_message = 3;
765
+ }
766
+
767
+ // The message that presents row level error info in a request.
768
+ message RowError {
769
+ // Error code for `RowError`.
770
+ enum RowErrorCode {
771
+ // Default error.
772
+ ROW_ERROR_CODE_UNSPECIFIED = 0;
773
+
774
+ // One or more fields in the row has errors.
775
+ FIELDS_ERROR = 1;
776
+ }
777
+
778
+ // Index of the malformed row in the request.
779
+ int64 index = 1;
780
+
781
+ // Structured error reason for a row error.
782
+ RowErrorCode code = 2;
783
+
784
+ // Description of the issue encountered when processing the row.
785
+ string message = 3;
786
+ }