• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2023 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
15syntax = "proto3";
16
17package google.cloud.bigquery.storage.v1;
18
19import "google/api/annotations.proto";
20import "google/api/client.proto";
21import "google/api/field_behavior.proto";
22import "google/api/resource.proto";
23import "google/cloud/bigquery/storage/v1/arrow.proto";
24import "google/cloud/bigquery/storage/v1/avro.proto";
25import "google/cloud/bigquery/storage/v1/protobuf.proto";
26import "google/cloud/bigquery/storage/v1/stream.proto";
27import "google/cloud/bigquery/storage/v1/table.proto";
28import "google/protobuf/timestamp.proto";
29import "google/protobuf/wrappers.proto";
30import "google/rpc/status.proto";
31
32option csharp_namespace = "Google.Cloud.BigQuery.Storage.V1";
33option go_package = "cloud.google.com/go/bigquery/storage/apiv1/storagepb;storagepb";
34option java_multiple_files = true;
35option java_outer_classname = "StorageProto";
36option java_package = "com.google.cloud.bigquery.storage.v1";
37option php_namespace = "Google\\Cloud\\BigQuery\\Storage\\V1";
38option (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.
46service 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 100 MiB
82  // per response; read requests which attempt to read individual rows larger
83  // than 100 MiB 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
120service 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`.
232message 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`.
269message 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.
285message 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.
292message 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.
319message 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`.
371message 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`.
391message 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`.
403message 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`.
424message AppendRowsRequest {
425  // ProtoData contains the data rows and schema when constructing append
426  // requests.
427  message ProtoData {
428    // The protocol buffer schema used to serialize the data. Provide this value
429    // whenever:
430    //
431    // * You send the first request of an RPC connection.
432    //
433    // * You change the input schema.
434    //
435    // * You specify a new destination table.
436    ProtoSchema writer_schema = 1;
437
438    // Serialized row data in protobuf message format.
439    // Currently, the backend expects the serialized rows to adhere to
440    // proto2 semantics when appending rows, particularly with respect to
441    // how default values are encoded.
442    ProtoRows rows = 2;
443  }
444
445  // An enum to indicate how to interpret missing values of fields that are
446  // present in user schema but missing in rows. A missing value can represent a
447  // NULL or a column default value defined in BigQuery table schema.
448  enum MissingValueInterpretation {
449    // Invalid missing value interpretation. Requests with this value will be
450    // rejected.
451    MISSING_VALUE_INTERPRETATION_UNSPECIFIED = 0;
452
453    // Missing value is interpreted as NULL.
454    NULL_VALUE = 1;
455
456    // Missing value is interpreted as column default value if declared in the
457    // table schema, NULL otherwise.
458    DEFAULT_VALUE = 2;
459  }
460
461  // Required. The write_stream identifies the append operation. It must be
462  // provided in the following scenarios:
463  //
464  // * In the first request to an AppendRows connection.
465  //
466  // * In all subsequent requests to an AppendRows connection, if you use the
467  // same connection to write to multiple tables or change the input schema for
468  // default streams.
469  //
470  // For explicitly created write streams, the format is:
471  //
472  // * `projects/{project}/datasets/{dataset}/tables/{table}/streams/{id}`
473  //
474  // For the special default stream, the format is:
475  //
476  // * `projects/{project}/datasets/{dataset}/tables/{table}/streams/_default`.
477  //
478  // An example of a possible sequence of requests with write_stream fields
479  // within a single connection:
480  //
481  // * r1: {write_stream: stream_name_1}
482  //
483  // * r2: {write_stream: /*omit*/}
484  //
485  // * r3: {write_stream: /*omit*/}
486  //
487  // * r4: {write_stream: stream_name_2}
488  //
489  // * r5: {write_stream: stream_name_2}
490  //
491  // The destination changed in request_4, so the write_stream field must be
492  // populated in all subsequent requests in this stream.
493  string write_stream = 1 [
494    (google.api.field_behavior) = REQUIRED,
495    (google.api.resource_reference) = {
496      type: "bigquerystorage.googleapis.com/WriteStream"
497    }
498  ];
499
500  // If present, the write is only performed if the next append offset is same
501  // as the provided value. If not present, the write is performed at the
502  // current end of stream. Specifying a value for this field is not allowed
503  // when calling AppendRows for the '_default' stream.
504  google.protobuf.Int64Value offset = 2;
505
506  // Input rows. The `writer_schema` field must be specified at the initial
507  // request and currently, it will be ignored if specified in following
508  // requests. Following requests must have data in the same format as the
509  // initial request.
510  oneof rows {
511    // Rows in proto format.
512    ProtoData proto_rows = 4;
513  }
514
515  // Id set by client to annotate its identity. Only initial request setting is
516  // respected.
517  string trace_id = 6;
518
519  // A map to indicate how to interpret missing value for some fields. Missing
520  // values are fields present in user schema but missing in rows. The key is
521  // the field name. The value is the interpretation of missing values for the
522  // field.
523  //
524  // For example, a map {'foo': NULL_VALUE, 'bar': DEFAULT_VALUE} means all
525  // missing values in field foo are interpreted as NULL, all missing values in
526  // field bar are interpreted as the default value of field bar in table
527  // schema.
528  //
529  // If a field is not in this map and has missing values, the missing values
530  // in this field are interpreted as NULL.
531  //
532  // This field only applies to the current request, it won't affect other
533  // requests on the connection.
534  //
535  // Currently, field name can only be top-level column name, can't be a struct
536  // field path like 'foo.bar'.
537  map<string, MissingValueInterpretation> missing_value_interpretations = 7;
538
539  // Optional. Default missing value interpretation for all columns in the
540  // table. When a value is specified on an `AppendRowsRequest`, it is applied
541  // to all requests on the connection from that point forward, until a
542  // subsequent `AppendRowsRequest` sets it to a different value.
543  // `missing_value_interpretation` can override
544  // `default_missing_value_interpretation`. For example, if you want to write
545  // `NULL` instead of using default values for some columns, you can set
546  // `default_missing_value_interpretation` to `DEFAULT_VALUE` and at the same
547  // time, set `missing_value_interpretations` to `NULL_VALUE` on those columns.
548  MissingValueInterpretation default_missing_value_interpretation = 8
549      [(google.api.field_behavior) = OPTIONAL];
550}
551
552// Response message for `AppendRows`.
553message AppendRowsResponse {
554  // AppendResult is returned for successful append requests.
555  message AppendResult {
556    // The row offset at which the last append occurred. The offset will not be
557    // set if appending using default streams.
558    google.protobuf.Int64Value offset = 1;
559  }
560
561  oneof response {
562    // Result if the append is successful.
563    AppendResult append_result = 1;
564
565    // Error returned when problems were encountered.  If present,
566    // it indicates rows were not accepted into the system.
567    // Users can retry or continue with other append requests within the
568    // same connection.
569    //
570    // Additional information about error signalling:
571    //
572    // ALREADY_EXISTS: Happens when an append specified an offset, and the
573    // backend already has received data at this offset.  Typically encountered
574    // in retry scenarios, and can be ignored.
575    //
576    // OUT_OF_RANGE: Returned when the specified offset in the stream is beyond
577    // the current end of the stream.
578    //
579    // INVALID_ARGUMENT: Indicates a malformed request or data.
580    //
581    // ABORTED: Request processing is aborted because of prior failures.  The
582    // request can be retried if previous failure is addressed.
583    //
584    // INTERNAL: Indicates server side error(s) that can be retried.
585    google.rpc.Status error = 2;
586  }
587
588  // If backend detects a schema update, pass it to user so that user can
589  // use it to input new type of message. It will be empty when no schema
590  // updates have occurred.
591  TableSchema updated_schema = 3;
592
593  // If a request failed due to corrupted rows, no rows in the batch will be
594  // appended. The API will return row level error info, so that the caller can
595  // remove the bad rows and retry the request.
596  repeated RowError row_errors = 4;
597
598  // The target of the append operation. Matches the write_stream in the
599  // corresponding request.
600  string write_stream = 5;
601}
602
603// Request message for `GetWriteStreamRequest`.
604message GetWriteStreamRequest {
605  // Required. Name of the stream to get, in the form of
606  // `projects/{project}/datasets/{dataset}/tables/{table}/streams/{stream}`.
607  string name = 1 [
608    (google.api.field_behavior) = REQUIRED,
609    (google.api.resource_reference) = {
610      type: "bigquerystorage.googleapis.com/WriteStream"
611    }
612  ];
613
614  // Indicates whether to get full or partial view of the WriteStream. If
615  // not set, view returned will be basic.
616  WriteStreamView view = 3;
617}
618
619// Request message for `BatchCommitWriteStreams`.
620message BatchCommitWriteStreamsRequest {
621  // Required. Parent table that all the streams should belong to, in the form
622  // of `projects/{project}/datasets/{dataset}/tables/{table}`.
623  string parent = 1 [
624    (google.api.field_behavior) = REQUIRED,
625    (google.api.resource_reference) = { type: "bigquery.googleapis.com/Table" }
626  ];
627
628  // Required. The group of streams that will be committed atomically.
629  repeated string write_streams = 2 [(google.api.field_behavior) = REQUIRED];
630}
631
632// Response message for `BatchCommitWriteStreams`.
633message BatchCommitWriteStreamsResponse {
634  // The time at which streams were committed in microseconds granularity.
635  // This field will only exist when there are no stream errors.
636  // **Note** if this field is not set, it means the commit was not successful.
637  google.protobuf.Timestamp commit_time = 1;
638
639  // Stream level error if commit failed. Only streams with error will be in
640  // the list.
641  // If empty, there is no error and all streams are committed successfully.
642  // If non empty, certain streams have errors and ZERO stream is committed due
643  // to atomicity guarantee.
644  repeated StorageError stream_errors = 2;
645}
646
647// Request message for invoking `FinalizeWriteStream`.
648message FinalizeWriteStreamRequest {
649  // Required. Name of the stream to finalize, in the form of
650  // `projects/{project}/datasets/{dataset}/tables/{table}/streams/{stream}`.
651  string name = 1 [
652    (google.api.field_behavior) = REQUIRED,
653    (google.api.resource_reference) = {
654      type: "bigquerystorage.googleapis.com/WriteStream"
655    }
656  ];
657}
658
659// Response message for `FinalizeWriteStream`.
660message FinalizeWriteStreamResponse {
661  // Number of rows in the finalized stream.
662  int64 row_count = 1;
663}
664
665// Request message for `FlushRows`.
666message FlushRowsRequest {
667  // Required. The stream that is the target of the flush operation.
668  string write_stream = 1 [
669    (google.api.field_behavior) = REQUIRED,
670    (google.api.resource_reference) = {
671      type: "bigquerystorage.googleapis.com/WriteStream"
672    }
673  ];
674
675  // Ending offset of the flush operation. Rows before this offset(including
676  // this offset) will be flushed.
677  google.protobuf.Int64Value offset = 2;
678}
679
680// Respond message for `FlushRows`.
681message FlushRowsResponse {
682  // The rows before this offset (including this offset) are flushed.
683  int64 offset = 1;
684}
685
686// Structured custom BigQuery Storage error message. The error can be attached
687// as error details in the returned rpc Status. In particular, the use of error
688// codes allows more structured error handling, and reduces the need to evaluate
689// unstructured error text strings.
690message StorageError {
691  // Error code for `StorageError`.
692  enum StorageErrorCode {
693    // Default error.
694    STORAGE_ERROR_CODE_UNSPECIFIED = 0;
695
696    // Table is not found in the system.
697    TABLE_NOT_FOUND = 1;
698
699    // Stream is already committed.
700    STREAM_ALREADY_COMMITTED = 2;
701
702    // Stream is not found.
703    STREAM_NOT_FOUND = 3;
704
705    // Invalid Stream type.
706    // For example, you try to commit a stream that is not pending.
707    INVALID_STREAM_TYPE = 4;
708
709    // Invalid Stream state.
710    // For example, you try to commit a stream that is not finalized or is
711    // garbaged.
712    INVALID_STREAM_STATE = 5;
713
714    // Stream is finalized.
715    STREAM_FINALIZED = 6;
716
717    // There is a schema mismatch and it is caused by user schema has extra
718    // field than bigquery schema.
719    SCHEMA_MISMATCH_EXTRA_FIELDS = 7;
720
721    // Offset already exists.
722    OFFSET_ALREADY_EXISTS = 8;
723
724    // Offset out of range.
725    OFFSET_OUT_OF_RANGE = 9;
726
727    // Customer-managed encryption key (CMEK) not provided for CMEK-enabled
728    // data.
729    CMEK_NOT_PROVIDED = 10;
730
731    // Customer-managed encryption key (CMEK) was incorrectly provided.
732    INVALID_CMEK_PROVIDED = 11;
733
734    // There is an encryption error while using customer-managed encryption key.
735    CMEK_ENCRYPTION_ERROR = 12;
736
737    // Key Management Service (KMS) service returned an error, which can be
738    // retried.
739    KMS_SERVICE_ERROR = 13;
740
741    // Permission denied while using customer-managed encryption key.
742    KMS_PERMISSION_DENIED = 14;
743  }
744
745  // BigQuery Storage specific error code.
746  StorageErrorCode code = 1;
747
748  // Name of the failed entity.
749  string entity = 2;
750
751  // Message that describes the error.
752  string error_message = 3;
753}
754
755// The message that presents row level error info in a request.
756message RowError {
757  // Error code for `RowError`.
758  enum RowErrorCode {
759    // Default error.
760    ROW_ERROR_CODE_UNSPECIFIED = 0;
761
762    // One or more fields in the row has errors.
763    FIELDS_ERROR = 1;
764  }
765
766  // Index of the malformed row in the request.
767  int64 index = 1;
768
769  // Structured error reason for a row error.
770  RowErrorCode code = 2;
771
772  // Description of the issue encountered when processing the row.
773  string message = 3;
774}
775