xref: /aosp_15_r20/external/googleapis/google/cloud/bigquery/storage/v1/table.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
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/field_behavior.proto";
20
21option csharp_namespace = "Google.Cloud.BigQuery.Storage.V1";
22option go_package = "cloud.google.com/go/bigquery/storage/apiv1/storagepb;storagepb";
23option java_multiple_files = true;
24option java_outer_classname = "TableProto";
25option java_package = "com.google.cloud.bigquery.storage.v1";
26option php_namespace = "Google\\Cloud\\BigQuery\\Storage\\V1";
27
28// Schema of a table. This schema is a subset of
29// google.cloud.bigquery.v2.TableSchema containing information necessary to
30// generate valid message to write to BigQuery.
31message TableSchema {
32  // Describes the fields in a table.
33  repeated TableFieldSchema fields = 1;
34}
35
36// TableFieldSchema defines a single field/column within a table schema.
37message TableFieldSchema {
38  enum Type {
39    // Illegal value
40    TYPE_UNSPECIFIED = 0;
41
42    // 64K, UTF8
43    STRING = 1;
44
45    // 64-bit signed
46    INT64 = 2;
47
48    // 64-bit IEEE floating point
49    DOUBLE = 3;
50
51    // Aggregate type
52    STRUCT = 4;
53
54    // 64K, Binary
55    BYTES = 5;
56
57    // 2-valued
58    BOOL = 6;
59
60    // 64-bit signed usec since UTC epoch
61    TIMESTAMP = 7;
62
63    // Civil date - Year, Month, Day
64    DATE = 8;
65
66    // Civil time - Hour, Minute, Second, Microseconds
67    TIME = 9;
68
69    // Combination of civil date and civil time
70    DATETIME = 10;
71
72    // Geography object
73    GEOGRAPHY = 11;
74
75    // Numeric value
76    NUMERIC = 12;
77
78    // BigNumeric value
79    BIGNUMERIC = 13;
80
81    // Interval
82    INTERVAL = 14;
83
84    // JSON, String
85    JSON = 15;
86
87    // RANGE
88    RANGE = 16;
89  }
90
91  enum Mode {
92    // Illegal value
93    MODE_UNSPECIFIED = 0;
94
95    NULLABLE = 1;
96
97    REQUIRED = 2;
98
99    REPEATED = 3;
100  }
101
102  // Represents the type of a field element.
103  message FieldElementType {
104    // Required. The type of a field element.
105    Type type = 1 [(google.api.field_behavior) = REQUIRED];
106  }
107
108  // Required. The field name. The name must contain only letters (a-z, A-Z),
109  // numbers (0-9), or underscores (_), and must start with a letter or
110  // underscore. The maximum length is 128 characters.
111  string name = 1 [(google.api.field_behavior) = REQUIRED];
112
113  // Required. The field data type.
114  Type type = 2 [(google.api.field_behavior) = REQUIRED];
115
116  // Optional. The field mode. The default value is NULLABLE.
117  Mode mode = 3 [(google.api.field_behavior) = OPTIONAL];
118
119  // Optional. Describes the nested schema fields if the type property is set to
120  // STRUCT.
121  repeated TableFieldSchema fields = 4 [(google.api.field_behavior) = OPTIONAL];
122
123  // Optional. The field description. The maximum length is 1,024 characters.
124  string description = 6 [(google.api.field_behavior) = OPTIONAL];
125
126  // Optional. Maximum length of values of this field for STRINGS or BYTES.
127  //
128  // If max_length is not specified, no maximum length constraint is imposed
129  // on this field.
130  //
131  // If type = "STRING", then max_length represents the maximum UTF-8
132  // length of strings in this field.
133  //
134  // If type = "BYTES", then max_length represents the maximum number of
135  // bytes in this field.
136  //
137  // It is invalid to set this field if type is not "STRING" or "BYTES".
138  int64 max_length = 7 [(google.api.field_behavior) = OPTIONAL];
139
140  // Optional. Precision (maximum number of total digits in base 10) and scale
141  // (maximum number of digits in the fractional part in base 10) constraints
142  // for values of this field for NUMERIC or BIGNUMERIC.
143  //
144  // It is invalid to set precision or scale if type is not "NUMERIC" or
145  // "BIGNUMERIC".
146  //
147  // If precision and scale are not specified, no value range constraint is
148  // imposed on this field insofar as values are permitted by the type.
149  //
150  // Values of this NUMERIC or BIGNUMERIC field must be in this range when:
151  //
152  // * Precision (P) and scale (S) are specified:
153  //   [-10^(P-S) + 10^(-S), 10^(P-S) - 10^(-S)]
154  // * Precision (P) is specified but not scale (and thus scale is
155  //   interpreted to be equal to zero):
156  //   [-10^P + 1, 10^P - 1].
157  //
158  // Acceptable values for precision and scale if both are specified:
159  //
160  // * If type = "NUMERIC":
161  //   1 <= precision - scale <= 29 and 0 <= scale <= 9.
162  // * If type = "BIGNUMERIC":
163  //   1 <= precision - scale <= 38 and 0 <= scale <= 38.
164  //
165  // Acceptable values for precision if only precision is specified but not
166  // scale (and thus scale is interpreted to be equal to zero):
167  //
168  // * If type = "NUMERIC": 1 <= precision <= 29.
169  // * If type = "BIGNUMERIC": 1 <= precision <= 38.
170  //
171  // If scale is specified but not precision, then it is invalid.
172  int64 precision = 8 [(google.api.field_behavior) = OPTIONAL];
173
174  // Optional. See documentation for precision.
175  int64 scale = 9 [(google.api.field_behavior) = OPTIONAL];
176
177  // Optional. A SQL expression to specify the [default value]
178  // (https://cloud.google.com/bigquery/docs/default-values) for this field.
179  string default_value_expression = 10 [(google.api.field_behavior) = OPTIONAL];
180
181  // Optional. The subtype of the RANGE, if the type of this field is RANGE. If
182  // the type is RANGE, this field is required. Possible values for the field
183  // element type of a RANGE include:
184  // * DATE
185  // * DATETIME
186  // * TIMESTAMP
187  FieldElementType range_element_type = 11
188      [(google.api.field_behavior) = OPTIONAL];
189}
190