stream.proto 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. // Copyright 2021 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. syntax = "proto3";
  15. package google.cloud.bigquery.storage.v1beta2;
  16. import "google/api/field_behavior.proto";
  17. import "google/api/resource.proto";
  18. import "google/cloud/bigquery/storage/v1beta2/arrow.proto";
  19. import "google/cloud/bigquery/storage/v1beta2/avro.proto";
  20. import "google/cloud/bigquery/storage/v1beta2/table.proto";
  21. import "google/protobuf/timestamp.proto";
  22. option go_package = "google.golang.org/genproto/googleapis/cloud/bigquery/storage/v1beta2;storage";
  23. option java_multiple_files = true;
  24. option java_outer_classname = "StreamProto";
  25. option java_package = "com.google.cloud.bigquery.storage.v1beta2";
  26. option (google.api.resource_definition) = {
  27. type: "bigquery.googleapis.com/Table"
  28. pattern: "projects/{project}/datasets/{dataset}/tables/{table}"
  29. };
  30. // Data format for input or output data.
  31. enum DataFormat {
  32. DATA_FORMAT_UNSPECIFIED = 0;
  33. // Avro is a standard open source row based file format.
  34. // See https://avro.apache.org/ for more details.
  35. AVRO = 1;
  36. // Arrow is a standard open source column-based message format.
  37. // See https://arrow.apache.org/ for more details.
  38. ARROW = 2;
  39. }
  40. // Information about the ReadSession.
  41. message ReadSession {
  42. option (google.api.resource) = {
  43. type: "bigquerystorage.googleapis.com/ReadSession"
  44. pattern: "projects/{project}/locations/{location}/sessions/{session}"
  45. };
  46. // Additional attributes when reading a table.
  47. message TableModifiers {
  48. // The snapshot time of the table. If not set, interpreted as now.
  49. google.protobuf.Timestamp snapshot_time = 1;
  50. }
  51. // Options dictating how we read a table.
  52. message TableReadOptions {
  53. // Names of the fields in the table that should be read. If empty, all
  54. // fields will be read. If the specified field is a nested field, all
  55. // the sub-fields in the field will be selected. The output field order is
  56. // unrelated to the order of fields in selected_fields.
  57. repeated string selected_fields = 1;
  58. // SQL text filtering statement, similar to a WHERE clause in a query.
  59. // Aggregates are not supported.
  60. //
  61. // Examples: "int_field > 5"
  62. // "date_field = CAST('2014-9-27' as DATE)"
  63. // "nullable_field is not NULL"
  64. // "st_equals(geo_field, st_geofromtext("POINT(2, 2)"))"
  65. // "numeric_field BETWEEN 1.0 AND 5.0"
  66. //
  67. // Restricted to a maximum length for 1 MB.
  68. string row_restriction = 2;
  69. // Optional. Options specific to the Apache Arrow output format.
  70. ArrowSerializationOptions arrow_serialization_options = 3 [(google.api.field_behavior) = OPTIONAL];
  71. }
  72. // Output only. Unique identifier for the session, in the form
  73. // `projects/{project_id}/locations/{location}/sessions/{session_id}`.
  74. string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
  75. // Output only. Time at which the session becomes invalid. After this time, subsequent
  76. // requests to read this Session will return errors. The expire_time is
  77. // automatically assigned and currently cannot be specified or updated.
  78. google.protobuf.Timestamp expire_time = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
  79. // Immutable. Data format of the output data.
  80. DataFormat data_format = 3 [(google.api.field_behavior) = IMMUTABLE];
  81. // The schema for the read. If read_options.selected_fields is set, the
  82. // schema may be different from the table schema as it will only contain
  83. // the selected fields.
  84. oneof schema {
  85. // Output only. Avro schema.
  86. AvroSchema avro_schema = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
  87. // Output only. Arrow schema.
  88. ArrowSchema arrow_schema = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
  89. }
  90. // Immutable. Table that this ReadSession is reading from, in the form
  91. // `projects/{project_id}/datasets/{dataset_id}/tables/{table_id}
  92. string table = 6 [
  93. (google.api.field_behavior) = IMMUTABLE,
  94. (google.api.resource_reference) = {
  95. type: "bigquery.googleapis.com/Table"
  96. }
  97. ];
  98. // Optional. Any modifiers which are applied when reading from the specified table.
  99. TableModifiers table_modifiers = 7 [(google.api.field_behavior) = OPTIONAL];
  100. // Optional. Read options for this session (e.g. column selection, filters).
  101. TableReadOptions read_options = 8 [(google.api.field_behavior) = OPTIONAL];
  102. // Output only. A list of streams created with the session.
  103. //
  104. // At least one stream is created with the session. In the future, larger
  105. // request_stream_count values *may* result in this list being unpopulated,
  106. // in that case, the user will need to use a List method to get the streams
  107. // instead, which is not yet available.
  108. repeated ReadStream streams = 10 [(google.api.field_behavior) = OUTPUT_ONLY];
  109. }
  110. // Information about a single stream that gets data out of the storage system.
  111. // Most of the information about `ReadStream` instances is aggregated, making
  112. // `ReadStream` lightweight.
  113. message ReadStream {
  114. option (google.api.resource) = {
  115. type: "bigquerystorage.googleapis.com/ReadStream"
  116. pattern: "projects/{project}/locations/{location}/sessions/{session}/streams/{stream}"
  117. };
  118. // Output only. Name of the stream, in the form
  119. // `projects/{project_id}/locations/{location}/sessions/{session_id}/streams/{stream_id}`.
  120. string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
  121. }
  122. // Information about a single stream that gets data inside the storage system.
  123. message WriteStream {
  124. option (google.api.resource) = {
  125. type: "bigquerystorage.googleapis.com/WriteStream"
  126. pattern: "projects/{project}/datasets/{dataset}/tables/{table}/streams/{stream}"
  127. };
  128. // Type enum of the stream.
  129. enum Type {
  130. // Unknown type.
  131. TYPE_UNSPECIFIED = 0;
  132. // Data will commit automatically and appear as soon as the write is
  133. // acknowledged.
  134. COMMITTED = 1;
  135. // Data is invisible until the stream is committed.
  136. PENDING = 2;
  137. // Data is only visible up to the offset to which it was flushed.
  138. BUFFERED = 3;
  139. }
  140. // Output only. Name of the stream, in the form
  141. // `projects/{project}/datasets/{dataset}/tables/{table}/streams/{stream}`.
  142. string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
  143. // Immutable. Type of the stream.
  144. Type type = 2 [(google.api.field_behavior) = IMMUTABLE];
  145. // Output only. Create time of the stream. For the _default stream, this is the
  146. // creation_time of the table.
  147. google.protobuf.Timestamp create_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
  148. // Output only. Commit time of the stream.
  149. // If a stream is of `COMMITTED` type, then it will have a commit_time same as
  150. // `create_time`. If the stream is of `PENDING` type, commit_time being empty
  151. // means it is not committed.
  152. google.protobuf.Timestamp commit_time = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
  153. // Output only. The schema of the destination table. It is only returned in
  154. // `CreateWriteStream` response. Caller should generate data that's
  155. // compatible with this schema to send in initial `AppendRowsRequest`.
  156. // The table schema could go out of date during the life time of the stream.
  157. TableSchema table_schema = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
  158. }