google_cloud_bigquery/http/table/
mod.rs

1use crate::http::types::{Collation, EncryptionConfiguration};
2
3pub mod delete;
4pub mod get;
5pub mod get_iam_policy;
6pub mod insert;
7pub mod list;
8pub mod patch;
9pub mod set_iam_policy;
10pub mod test_iam_permissions;
11
12#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
13#[serde(rename_all = "camelCase")]
14pub struct TableReference {
15    /// Required. The ID of the project containing this table.
16    pub project_id: String,
17    /// Required. The ID of the dataset containing this table.
18    pub dataset_id: String,
19    /// Required. The ID of the table.
20    /// The ID must contain only letters (a-z, A-Z), numbers (0-9), or underscores (_).
21    /// The maximum length is 1,024 characters. Certain operations allow suffixing of the table ID with a partition decorator, such as sample_table$20190123.
22    pub table_id: String,
23}
24
25impl TableReference {
26    pub fn resource(&self) -> String {
27        format!(
28            "projects/{}/datasets/{}/tables/{}",
29            &self.project_id, &self.dataset_id, &self.table_id
30        )
31    }
32}
33
34#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
35#[serde(rename_all = "camelCase")]
36pub struct CsvOptions {
37    /// Optional. The separator character for fields in a CSV file.
38    /// The separator is interpreted as a single byte.
39    /// For files encoded in ISO-8859-1, any single character can be used as a separator.
40    /// For files encoded in UTF-8,
41    /// characters represented in decimal range 1-127 (U+0001-U+007F) can be used without any modification.
42    /// UTF-8 characters encoded with multiple bytes (i.e. U+0080 and above) will
43    /// have only the first byte used for separating fields.
44    /// The remaining bytes will be treated as a part of the field.
45    /// BigQuery also supports the escape sequence "\t" (U+0009) to specify a tab separator.
46    /// The default value is comma (",", U+002C).
47    pub field_delimiter: Option<String>,
48    /// Optional. The number of rows at the top of a CSV file that BigQuery will skip when reading the data.
49    /// The default value is 0.
50    /// This property is useful if you have header rows in the file that should be skipped.
51    /// When autodetect is on, the behavior is the following:
52    ///
53    /// skipLeadingRows unspecified - Autodetect tries to detect headers in the first row.
54    ///     If they are not detected, the row is read as data.
55    ///     Otherwise data is read starting from the second row.
56    /// skipLeadingRows is 0 - Instructs autodetect that there are no headers and data should be read starting from the first row.
57    /// skipLeadingRows = N > 0 - Autodetect skips N-1 rows and tries to detect headers in row N.
58    ///     If headers are not detected, row N is just skipped. Otherwise row N is used to extract column names for the detected schema.
59    #[serde(deserialize_with = "crate::http::from_str_option")]
60    #[serde(default)]
61    pub skip_leading_rows: Option<i64>,
62    /// Optional. The value that is used to quote data sections in a CSV file.
63    /// BigQuery converts the string to ISO-8859-1 encoding,
64    /// and then uses the first byte of the encoded string to split the data in its raw, binary state.
65    /// The default value is a double-quote (").
66    /// If your data does not contain quoted sections, set the property value to an empty string.
67    /// If your data contains quoted newline characters,
68    /// you must also set the allowQuotedNewlines property to true.
69    /// To include the specific quote character within a quoted value,
70    /// precede it with an additional matching quote character.
71    /// For example, if you want to escape the default character ' " ', use ' "" '.
72    pub quote: Option<String>,
73    /// Optional. Indicates if BigQuery should allow quoted data sections that contain newline characters in a CSV file.
74    /// The default value is false.
75    pub allow_quote_new_lines: Option<bool>,
76    /// Optional. Indicates if BigQuery should accept rows that are missing trailing optional columns.
77    /// If true, BigQuery treats missing trailing columns as null values.
78    /// If false, records with missing trailing columns are treated as bad records,
79    /// and if there are too many bad records, an invalid error is returned in the job result.
80    /// The default value is false.
81    pub allow_jagged_rows: Option<bool>,
82    /// Optional. The character encoding of the data.
83    /// The supported values are UTF-8, ISO-8859-1, UTF-16BE, UTF-16LE, UTF-32BE, and UTF-32LE.
84    /// The default value is UTF-8.
85    /// BigQuery decodes the data after the raw, binary data has been
86    /// split using the values of the quote and fieldDelimiter properties.
87    pub encoding: Option<String>,
88    /// Optional. Indicates if the embedded ASCII control characters
89    /// (the first 32 characters in the ASCII-table, from '\x00' to '\x1F') are preserved.
90    pub preserve_ascii_control_characters: Option<bool>,
91}
92#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
93#[serde(rename_all = "camelCase")]
94pub struct BigtableOptions {
95    /// Optional. tabledata.list of column families to expose in the table schema along with their types.
96    /// This list restricts the column families that can be referenced in queries and specifies their value types.
97    /// You can use this list to do type conversions - see the 'type' field for more details. If you leave this list empty, all column families are present in the table schema and their values are read as BYTES. During a query only the column families referenced in that query are read from Bigtable.
98    pub column_families: Vec<BigtableColumnFamily>,
99    /// Optional. If field is true, then the column families that are not specified in columnFamilies list are not exposed in the table schema.
100    /// Otherwise, they are read with BYTES type values.
101    /// The default value is false.
102    pub ignore_unspecified_column_families: Option<bool>,
103    /// Optional. If field is true, then the rowkey column families will be read and converted to string.
104    /// Otherwise they are read with BYTES type values and users need to manually cast them with CAST if necessary.
105    /// The default value is false.
106    pub read_rowkey_as_string: Option<bool>,
107}
108#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
109#[serde(rename_all = "camelCase")]
110pub struct BigtableColumnFamily {
111    /// Identifier of the column family.
112    pub family_id: String,
113    /// Optional. The type to convert the value in cells of this column family.
114    /// The values are expected to be encoded using HBase Bytes.toBytes function when using the BINARY encoding value. Following BigQuery types are allowed (case-sensitive) - BYTES STRING INTEGER FLOAT BOOLEAN Default type is BYTES.
115    /// This can be overridden for a specific column by listing that column in 'columns' and specifying a type for it.
116    #[serde(rename(serialize = "type", deserialize = "type"))]
117    pub data_type: Option<String>,
118    /// Optional. The encoding of the values when the type is not STRING.
119    /// Acceptable encoding values are: TEXT - indicates values are alphanumeric text strings. BINARY - indicates values are encoded using HBase Bytes.toBytes family of functions.
120    /// This can be overridden for a specific column by listing that column in 'columns' and specifying an encoding for it.
121    pub encoding: Option<String>,
122    /// Optional. Lists of columns that should be exposed as individual fields
123    /// as opposed to a list of (column name, value) pairs.
124    /// All columns whose qualifier matches a qualifier in this list can be accessed as ..
125    /// Other columns can be accessed as a list through .Column field.
126    pub columns: Option<Vec<BigtableColumn>>,
127    /// Optional. If this is set only the latest version of value are exposed for all columns in this column family.
128    /// This can be overridden for a specific column by listing that column in 'columns' and specifying a different setting for that column.
129    pub only_read_latest: Option<bool>,
130}
131#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
132#[serde(rename_all = "camelCase")]
133pub struct BigtableColumn {
134    /// [Required] Qualifier of the column. Columns in the parent column family that has this exact qualifier are exposed as . field. If the qualifier is valid UTF-8 string, it can be specified in the qualifierString field. Otherwise, a base-64 encoded value must be set to qualifierEncoded. The column field name is the same as the column qualifier. However, if the qualifier is not a valid BigQuery field identifier i.e.
135    /// does not match [a-zA-Z][a-zA-Z0-9_]*, a valid identifier must be provided as fieldName.
136    pub qualifier_encoded: Option<String>,
137    pub qualifier_string: Option<String>,
138    /// Optional. If the qualifier is not a valid BigQuery field identifier i.e.
139    /// does not match [a-zA-Z][a-zA-Z0-9_]*, a valid identifier must be provided as the column field name and is used as field name in queries.
140    pub field_name: Option<String>,
141    /// Optional. The type to convert the value in cells of this column.
142    /// The values are expected to be encoded using HBase Bytes.
143    /// toBytes function when using the BINARY encoding value. Following BigQuery types are allowed (case-sensitive) - BYTES STRING INTEGER FLOAT BOOLEAN Default type is BYTES. 'type' can also be set at the column family level. However, the setting at this level takes precedence if 'type' is set at both levels.
144    #[serde(rename(serialize = "type", deserialize = "type"))]
145    pub data_type: Option<String>,
146    /// Optional. The encoding of the values when the type is not STRING.
147    /// Acceptable encoding values are: TEXT - indicates values are alphanumeric text strings.
148    /// BINARY - indicates values are encoded using HBase Bytes.toBytes family of functions.
149    /// 'encoding' can also be set at the column family level.
150    /// However, the setting at this level takes precedence if 'encoding' is set at both levels.
151    pub encoding: Option<String>,
152    /// Optional. If this is set, only the latest version of value in this column are exposed.
153    /// 'onlyReadLatest' can also be set at the column family level.
154    /// However, the setting at this level takes precedence if 'onlyReadLatest' is set at both levels.
155    pub only_read_latest: Option<bool>,
156}
157
158#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
159#[serde(rename_all = "camelCase")]
160pub struct GoogleSheetsOptions {
161    /// Optional. The number of rows at the top of a sheet that BigQuery will skip when reading the data.
162    /// The default value is 0. This property is useful if you have header rows that should be skipped.
163    /// When autodetect is on, the behavior is the following:
164    /// * skipLeadingRows unspecified - Autodetect tries to detect headers in the first row.
165    ///   If they are not detected, the row is read as data.
166    ///   Otherwise data is read starting from the second row.
167    /// * skipLeadingRows is 0 - Instructs autodetect that there are no headers and data should be read starting from the first row.
168    /// * skipLeadingRows = N > 0 - Autodetect skips N-1 rows and tries to detect headers in row N.
169    ///   If headers are not detected, row N is just skipped.
170    ///   Otherwise row N is used to extract column names for the detected schema.
171    #[serde(deserialize_with = "crate::http::from_str_option")]
172    #[serde(default)]
173    pub skip_leading_rows: Option<i64>,
174    /// Optional. Range of a sheet to query from. Only used when non-empty.
175    /// Typical format: sheet_name!top_left_cell_id:bottom_right_cell_id For example: sheet1!A1:B20
176    pub range: Option<String>,
177}
178#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
179#[serde(rename_all = "camelCase")]
180pub struct HivePartitioningOptions {
181    /// Optional. When set, what mode of hive partitioning to use when reading data.
182    /// The following modes are supported:
183    ///
184    /// AUTO: automatically infer partition key name(s) and type(s).
185    /// STRINGS: automatically infer partition key name(s). All types are strings.
186    /// CUSTOM: partition key schema is encoded in the source URI prefix.
187    /// Not all storage formats support hive partitioning.
188    /// Requesting hive partitioning on an unsupported format will lead to an error.
189    /// Currently supported formats are: JSON, CSV, ORC, Avro and Parquet.
190    pub mode: Option<String>,
191    /// Optional. When hive partition detection is requested,
192    /// a common prefix for all source uris must be required.
193    /// The prefix must end immediately before the partition key encoding begins.
194    /// For example, consider files following this data layout:
195    ///
196    /// gs://bucket/path_to_table/dt=2019-06-01/country=USA/id=7/file.avro
197    /// gs://bucket/path_to_table/dt=2019-05-31/country=CA/id=3/file.avro
198    ///
199    /// When hive partitioning is requested with either AUTO or STRINGS detection, the common prefix can be either of gs://bucket/path_to_table or gs://bucket/path_to_table/.
200    ///
201    /// CUSTOM detection requires encoding the partitioning schema immediately after the common prefix. For CUSTOM, any of
202    ///
203    /// gs://bucket/path_to_table/{dt:DATE}/{country:STRING}/{id:INTEGER}
204    /// gs://bucket/path_to_table/{dt:STRING}/{country:STRING}/{id:INTEGER}
205    /// gs://bucket/path_to_table/{dt:DATE}/{country:STRING}/{id:STRING}
206    /// would all be valid source URI prefixes.
207    pub source_uri_prefix: Option<String>,
208    /// Optional. If set to true, queries over this table require a partition filter that can be used for partition elimination to be specified.
209    /// Note that this field should only be true when creating a permanent external table or querying a temporary external table.
210    /// Hive-partitioned loads with requirePartitionFilter explicitly set to true will fail.
211    pub require_partition_filter: Option<bool>,
212    /// Output only. For permanent external tables,
213    /// this field is populated with the hive partition keys in the order they were inferred.
214    /// The types of the partition keys can be deduced by checking the table schema (which will include the partition keys). Not every API will populate this field in the output.
215    /// For example, Tables.Get will populate it, but Tables.List will not contain this field.
216    pub fields: Vec<String>,
217}
218
219#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
220#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
221pub enum DecimalTargetType {
222    /// Decimal values could be converted to NUMERIC type.
223    #[default]
224    Numeric,
225    /// Decimal values could be converted to BIGNUMERIC type.
226    Bignumeric,
227    /// Decimal values could be converted to STRING type.
228    String,
229}
230
231#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
232#[serde(rename_all = "camelCase")]
233pub struct AvroOptions {
234    /// Optional. If sourceFormat is set to "AVRO",
235    /// indicates whether to interpret logical types as the corresponding BigQuery data type
236    /// (for example, TIMESTAMP),
237    /// instead of using the raw type (for example, INTEGER).
238    pub use_avro_logical_types: Option<bool>,
239}
240
241#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
242#[serde(rename_all = "camelCase")]
243pub struct ParquetOptions {
244    /// Optional. Indicates whether to infer Parquet ENUM logical type as STRING instead of BYTES by default.
245    pub enum_as_string: Option<bool>,
246    /// Optional. Indicates whether to use schema inference specifically for Parquet LIST logical type.
247    pub enable_list_interface: Option<bool>,
248}
249
250#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
251#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
252pub enum ObjectMetadata {
253    /// Unspecified by default.
254    #[default]
255    ObjectMetadataUnspecified,
256    /// Directory listing of objects.
257    Simple,
258}
259
260#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
261#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
262pub enum MetadataCacheMode {
263    /// Unspecified metadata cache mode.
264    #[default]
265    MetadataCacheModeUnspecified,
266    /// Set this mode to trigger automatic background refresh of metadata cache from the external source.
267    /// Queries will use the latest available cache version within the table's maxStaleness interval.
268    Automatic,
269    /// Set this mode to enable triggering manual refresh of the metadata cache from external source.
270    /// Queries will use the latest manually triggered cache version within the table's maxStaleness interval.
271    Manual,
272}
273
274#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
275#[serde(rename_all = "camelCase")]
276pub struct Streamingbuffer {
277    /// Output only. A lower-bound estimate of the number of bytes currently in the streaming buffer.
278    pub estimated_bytes: String,
279    /// Output only. A lower-bound estimate of the number of rows currently in the streaming buffer.
280    pub estimated_rows: String,
281    /// Output only. Contains the timestamp of the oldest entry in the streaming buffer,
282    /// in milliseconds since the epoch, if the streaming buffer is available.
283    #[serde(deserialize_with = "crate::http::from_str_option")]
284    #[serde(default)]
285    pub oldest_entry_time: Option<u64>,
286}
287
288#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
289#[serde(rename_all = "camelCase")]
290pub struct SnapshotDefinition {
291    /// Required. Reference describing the ID of the table that was snapshot.
292    pub base_table_reference: TableReference,
293    /// Required. The time at which the base table was snapshot.
294    /// This value is reported in the JSON response using RFC3339 format.
295    #[serde(default, with = "time::serde::rfc3339::option")]
296    pub snapshot_time: Option<time::OffsetDateTime>,
297}
298
299#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
300#[serde(rename_all = "camelCase")]
301pub struct CloneDefinition {
302    /// Required. Reference describing the ID of the table that was cloned.
303    pub base_table_reference: TableReference,
304    /// Required. The time at which the base table was snapshot.
305    /// This value is reported in the JSON response using RFC3339 format.
306    #[serde(default, with = "time::serde::rfc3339::option")]
307    pub clone_time: Option<time::OffsetDateTime>,
308}
309
310#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
311#[serde(rename_all = "camelCase")]
312pub struct UserDefinedFunctionResource {
313    /// [Pick one] A code resource to load from a Google Cloud Storage URI (gs://bucket/path).
314    pub resource_uri: Option<String>,
315    /// [Pick one] An inline resource that contains code for a user-defined function (UDF).
316    /// Providing a inline code resource is equivalent to providing a URI for a file containing the same code.
317    pub inline_code: Option<String>,
318}
319
320#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
321#[serde(rename_all = "camelCase")]
322pub struct ViewDefinition {
323    /// Required. A query that BigQuery executes when the view is referenced.
324    pub query: String,
325    /// Describes user-defined function resources used in the query.
326    pub user_defined_function_resources: Option<Vec<UserDefinedFunctionResource>>,
327    /// Queries and views that reference this view must use the same flag value.
328    /// A wrapper is used here because the default value is True..
329    pub use_legacy_sql: bool,
330}
331
332#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
333#[serde(rename_all = "camelCase")]
334pub struct MaterializedViewDefinition {
335    /// Required. A query whose results are persisted.
336    pub query: String,
337    /// Output only. The time when this materialized view was last refreshed, in milliseconds since the epoch.
338    #[serde(deserialize_with = "crate::http::from_str_option")]
339    #[serde(default)]
340    pub last_refresh_time: Option<i64>,
341    /// Optional. Enable automatic refresh of the materialized view when the base table is updated. The default value is "true".
342    pub enable_refresh: Option<bool>,
343    /// Optional. The maximum frequency at which this materialized view will be refreshed. The default value is "1800000" (30 minutes).
344    #[serde(deserialize_with = "crate::http::from_str_option")]
345    #[serde(default)]
346    pub refresh_interval_ms: Option<u64>,
347}
348
349#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
350#[serde(rename_all = "camelCase")]
351pub struct PolicyTag {
352    /// A list of policy tag resource names. For example,
353    /// "projects/1/locations/eu/taxonomies/2/policyTags/3".
354    /// At most 1 policy tag is currently allowed.
355    pub names: Vec<String>,
356}
357
358#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
359#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
360pub enum RoundingMode {
361    /// Unspecified will default to using ROUND_HALF_AWAY_FROM_ZERO.
362    #[default]
363    RoundingModeUnspecified,
364    /// ROUND_HALF_AWAY_FROM_ZERO rounds half values away from zero when applying precision and scale upon writing of NUMERIC and BIGNUMERIC values.
365    /// For Scale: 0 1.1, 1.2, 1.3, 1.4 => 1 1.5, 1.6, 1.7, 1.8, 1.9 => 2.
366    RoundHalfAwayFromZero,
367    /// ROUND_HALF_EVEN rounds half values to the nearest even when applying precision and scale upon writing of NUMERIC and BIGNUMERIC values.
368    /// For Scale: 0 1.1, 1.2, 1.3, 1.4 => 1 1.5 => 2 1.6, 1.7, 1.8, 1.9 => 2 2.5 => 2
369    RoundHalfEven,
370}
371
372#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
373#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
374pub enum TableFieldMode {
375    #[default]
376    Nullable,
377    Required,
378    Repeated,
379}
380
381#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
382#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
383pub enum TableFieldType {
384    #[default]
385    String,
386    Bytes,
387    Integer,
388    Float,
389    Boolean,
390    Timestamp,
391    Record,
392    Date,
393    Time,
394    Datetime,
395    Numeric,
396    Decimal,
397    Bignumeric,
398    Interval,
399    Json,
400    // aliases
401    Bool,
402    Bigdecimal,
403    Int64,
404    Float64,
405    Struct,
406}
407#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
408#[serde(rename_all = "camelCase")]
409pub struct TableFieldSchema {
410    /// Required. The field name.
411    /// The name must contain only letters (a-z, A-Z), numbers (0-9), or underscores (_),
412    /// and must start with a letter or underscore.
413    /// The maximum length is 300 characters.
414    pub name: String,
415    /// Required. The field data type. Possible values include:
416    ///
417    /// STRING
418    /// BYTES
419    /// INTEGER (or INT64)
420    /// FLOAT (or FLOAT64)
421    /// BOOLEAN (or BOOL)
422    /// TIMESTAMP
423    /// DATE
424    /// TIME
425    /// DATETIME
426    /// GEOGRAPHY,
427    /// NUMERIC
428    /// BIGNUMERIC
429    /// RECORD (or STRUCT)
430    /// Use of RECORD/STRUCT indicates that the field contains a nested schema.
431    #[serde(rename(serialize = "type", deserialize = "type"))]
432    pub data_type: TableFieldType,
433    /// Optional. The field mode. Possible values include NULLABLE, REQUIRED and REPEATED.
434    /// The default value is NULLABLE.
435    pub mode: Option<TableFieldMode>,
436    /// Optional. Describes the nested schema fields if the type property is set to RECORD.
437    pub fields: Option<Vec<TableFieldSchema>>,
438    /// Optional. The field description. The maximum length is 1,024 characters.
439    pub description: Option<String>,
440    /// Optional. The policy tags attached to this field, used for field-level access control.
441    /// If not set, defaults to empty policyTags.
442    pub policy_tags: Option<PolicyTag>,
443    /// Optional. Maximum length of values of this field for STRINGS or BYTES.
444    /// If maxLength is not specified, no maximum length constraint is imposed on this field.
445    /// If type = "STRING", then maxLength represents the maximum UTF-8 length of strings in this field.
446    /// If type = "BYTES", then maxLength represents the maximum number of bytes in this field.
447    /// It is invalid to set this field if type ≠ "STRING" and ≠ "BYTES".
448    #[serde(deserialize_with = "crate::http::from_str_option")]
449    #[serde(default)]
450    pub max_length: Option<i64>,
451    /// Optional. Precision (maximum number of total digits in base 10) and scale (maximum number of digits in the fractional part in base 10) constraints for values of this field for NUMERIC or BIGNUMERIC.
452    ///
453    /// It is invalid to set precision or scale if type ≠ "NUMERIC" and ≠ "BIGNUMERIC".
454    ///
455    /// If precision and scale are not specified, no value range constraint is imposed on this field insofar as values are permitted by the type.
456    ///
457    /// Values of this NUMERIC or BIGNUMERIC field must be in this range when:
458    ///
459    /// Precision (P) and scale (S) are specified: [-10P-S + 10-S, 10P-S - 10-S]
460    /// Precision (P) is specified but not scale (and thus scale is interpreted to be equal to zero): [-10P + 1, 10P - 1].
461    /// Acceptable values for precision and scale if both are specified:
462    ///
463    /// If type = "NUMERIC": 1 ≤ precision - scale ≤ 29 and 0 ≤ scale ≤ 9.
464    /// If type = "BIGNUMERIC": 1 ≤ precision - scale ≤ 38 and 0 ≤ scale ≤ 38.
465    /// Acceptable values for precision if only precision is specified but not scale (and thus scale is interpreted to be equal to zero):
466    ///
467    /// If type = "NUMERIC": 1 ≤ precision ≤ 29.
468    /// If type = "BIGNUMERIC": 1 ≤ precision ≤ 38.
469    /// If scale is specified but not precision, then it is invalid.
470    #[serde(deserialize_with = "crate::http::from_str_option")]
471    #[serde(default)]
472    pub precision: Option<i64>,
473    /// Optional. See documentation for precision.
474    #[serde(deserialize_with = "crate::http::from_str_option")]
475    #[serde(default)]
476    pub scale: Option<i64>,
477    /// Optional. Specifies the rounding mode to be used when storing values of NUMERIC and BIGNUMERIC type.
478    pub rounding_mode: Option<RoundingMode>,
479    /// Optional. Field collation can be set only when the type of field is STRING. The following values are supported:
480    ///
481    /// 'und:ci': undetermined locale, case insensitive.
482    /// '': empty string. Default to case-sensitive behavior.
483    pub collation: Option<Collation>,
484    /// Optional. A SQL expression to specify the default value for this field.
485    /// https://cloud.google.com/bigquery/docs/default-values
486    pub default_value_expression: Option<String>,
487}
488
489#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
490#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
491pub enum TimePartitionType {
492    #[default]
493    Hour,
494    Day,
495    Month,
496    Year,
497}
498
499#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
500#[serde(rename_all = "camelCase")]
501pub struct TimePartitioning {
502    /// Required. The supported types are DAY, HOUR, MONTH, and YEAR,
503    /// which will generate one partition per day, hour, month, and year, respectively.
504    #[serde(rename(serialize = "type", deserialize = "type"))]
505    pub partition_type: TimePartitionType,
506    /// Optional. Number of milliseconds for which to keep the storage for a partition.
507    /// A wrapper is used here because 0 is an invalid value.
508    #[serde(deserialize_with = "crate::http::from_str_option")]
509    #[serde(default)]
510    pub expiration_ms: Option<i64>,
511    /// Optional. If not set, the table is partitioned by pseudo column '_PARTITIONTIME';
512    /// if set, the table is partitioned by this field.
513    /// The field must be a top-level TIMESTAMP or DATE field.
514    /// Its mode must be NULLABLE or REQUIRED.
515    /// A wrapper is used here because an empty string is an invalid value.
516    pub field: Option<String>,
517}
518#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
519#[serde(rename_all = "camelCase")]
520pub struct PartitionRange {
521    /// Required. [Experimental] The start of range partitioning, inclusive.
522    pub start: String,
523    /// Required. [Experimental] The end of range partitioning, exclusive.
524    pub end: String,
525    /// Required. [Experimental] The width of each interval.
526    pub interval: String,
527}
528
529#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
530#[serde(rename_all = "camelCase")]
531pub struct RangePartitioning {
532    /// Required. [Experimental] The table is partitioned by this field.
533    /// The field must be a top-level NULLABLE/REQUIRED field.
534    /// The only supported type is INTEGER/INT64.
535    pub field: String,
536    /// [Experimental] Defines the ranges for range partitioning.
537    pub range: PartitionRange,
538}
539
540#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
541#[serde(rename_all = "camelCase")]
542pub struct TableSchema {
543    /// Describes the fields in a table.
544    pub fields: Vec<TableFieldSchema>,
545}
546
547#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
548#[serde(rename_all = "camelCase")]
549pub struct Clustering {
550    /// One or more fields on which data should be clustered. Only top-level, non-repeated, simple-type fields are supported. The ordering of the clustering fields should be prioritized from most to least important for filtering purposes.
551    /// Additional information on limitations can be found here: https://cloud.google.com/bigquery/docs/creating-clustered-tables#limitations
552    pub fields: Vec<String>,
553}
554
555#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
556#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
557pub enum SourceFormat {
558    #[default]
559    Csv,
560    Avro,
561    NewlineDelimitedJson,
562    DatastoreBackup,
563    GoogleSheets,
564    Bigtable,
565    Parquet,
566    Orc,
567}
568
569#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
570#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
571pub enum DestinationFormat {
572    #[default]
573    Csv,
574    NewlineDelimitedJson,
575    Parquet,
576    Avro,
577    MlTfSavedModel,
578    MlXgboostBooster,
579}
580
581#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
582#[serde(rename_all = "camelCase")]
583pub struct ExternalDataConfiguration {
584    /// [Required] The fully-qualified URIs that point to your data in Google Cloud.
585    /// For Google Cloud Storage URIs:
586    /// Each URI can contain one '*' wildcard character and it must come after the 'bucket' name.
587    /// Size limits related to load jobs apply to external data sources.
588    /// For Google Cloud Bigtable URIs: Exactly one URI can be specified and it has be
589    /// a fully specified and valid HTTPS URL for a Google Cloud Bigtable table.
590    /// For Google Cloud Datastore backups,
591    /// exactly one URI can be specified. Also, the '*' wildcard character is not allowed.
592    pub source_uris: Vec<String>,
593    /// Optional. The schema for the data.
594    /// Schema is required for CSV and JSON formats if autodetect is not on.
595    /// Schema is disallowed for Google Cloud Bigtable,
596    /// Cloud Datastore backups, Avro, ORC and Parquet formats.
597    pub schema: Option<TableSchema>,
598    /// [Required] The data format. For CSV files, specify "CSV".
599    /// For Google sheets, specify "GOOGLE_SHEETS".
600    /// For newline-delimited JSON, specify "NEWLINE_DELIMITED_JSON".
601    /// For Avro files, specify "AVRO".
602    /// For Google Cloud Datastore backups, specify "DATASTORE_BACKUP".
603    /// For ORC files, specify "ORC". For Parquet files, specify "PARQUET".
604    /// [Beta] For Google Cloud Bigtable, specify "BIGTABLE".
605    pub source_format: SourceFormat,
606    /// Optional. The maximum number of bad records that BigQuery can ignore when reading data.
607    /// If the number of bad records exceeds this value, an invalid error is returned in the job result.
608    /// The default value is 0, which requires that all records are valid. This setting is ignored for Google Cloud Bigtable, Google Cloud Datastore backups, Avro, ORC and Parquet formats.
609    pub max_bad_records: i32,
610    /// Try to detect schema and format options automatically. Any option specified explicitly will be honored.
611    pub autodetect: bool,
612    /// Optional. Indicates if BigQuery should allow extra values that are not represented in the table schema.
613    /// If true, the extra values are ignored.
614    /// If false, records with extra columns are treated as bad records,
615    /// and if there are too many bad records, an invalid error is returned in the job result.
616    /// The default value is false.
617    /// The sourceFormat property determines what BigQuery treats as an extra value:
618    /// CSV:
619    /// Trailing columns JSON: Named values that don't match any column names
620    /// Google Cloud Bigtable: This setting is ignored.
621    /// Google Cloud Datastore backups: This setting is ignored.
622    /// Avro: This setting is ignored.
623    /// ORC: This setting is ignored.
624    /// Parquet: This setting is ignored.
625    pub ignore_unknown_values: Option<bool>,
626    /// Optional. The compression type of the data source.
627    /// Possible values include GZIP and NONE.
628    /// The default value is NONE.
629    /// This setting is ignored for Google Cloud Bigtable, Google Cloud Datastore backups, Avro, ORC and Parquet formats.
630    /// An empty string is an invalid value.
631    pub compression: Option<bool>,
632    /// Optional. Additional properties to set if sourceFormat is set to CSV.
633    pub csv_options: Option<CsvOptions>,
634    /// Optional. Additional options if sourceFormat is set to BIGTABLE.
635    pub bigtable_options: Option<BigtableOptions>,
636    /// Optional. Additional options if sourceFormat is set to GOOGLE_SHEETS.
637    pub google_sheets_options: Option<GoogleSheetsOptions>,
638    /// Optional. When set, configures hive partitioning support.
639    /// Not all storage formats support hive partitioning -- requesting hive partitioning on an unsupported format will lead to an error,
640    /// as will providing an invalid specification..
641    pub hive_partitioning_options: Option<HivePartitioningOptions>,
642    /// Optional. The connection specifying the credentials to be used to read external storage,
643    /// such as Azure Blob, Cloud Storage, or S3.
644    /// The connectionId can have the form "<project_id>.<location_id>.<connection_id>" or "projects/<project_id>/locations/<location_id>/connections/<connection_id>".
645    pub connection_id: Option<String>,
646    /// Defines the list of possible SQL data types to which the source decimal values are converted. This list and the precision and the scale parameters of the decimal field determine the target type. In the order of NUMERIC, BIGNUMERIC, and STRING, a type is picked if it is in the specified list and if it supports the precision and the scale. STRING supports all precision and scale values. If none of the listed types supports the precision and the scale, the type supporting the widest range in the specified list is picked, and if a value exceeds the supported range when reading the data, an error will be thrown.
647    ///
648    /// Example: Suppose the value of this field is ["NUMERIC", "BIGNUMERIC"]. If (precision,scale) is:
649    ///
650    /// (38,9) -> NUMERIC;
651    /// (39,9) -> BIGNUMERIC (NUMERIC cannot hold 30 integer digits);
652    /// (38,10) -> BIGNUMERIC (NUMERIC cannot hold 10 fractional digits);
653    /// (76,38) -> BIGNUMERIC;
654    /// (77,38) -> BIGNUMERIC (error if value exeeds supported range).
655    /// This field cannot contain duplicate types. The order of the types in this field is ignored. For example, ["BIGNUMERIC", "NUMERIC"] is the same as ["NUMERIC", "BIGNUMERIC"] and NUMERIC always takes precedence over BIGNUMERIC.
656    ///
657    /// Defaults to ["NUMERIC", "STRING"] for ORC and ["NUMERIC"] for the other file format
658    pub decimal_target_types: Option<Vec<DecimalTargetType>>,
659    /// Optional. Additional properties to set if sourceFormat is set to AVRO.
660    pub avro_options: Option<AvroOptions>,
661    /// Optional. Additional properties to set if sourceFormat is set to PARQUET.
662    pub parquet_options: Option<ParquetOptions>,
663    /// Optional. When creating an external table, the user can provide a reference file with the table schema.
664    /// This is enabled for the following formats: AVRO, PARQUET, ORC.
665    pub reference_file_schema_uri: Option<String>,
666    /// Optional. Metadata Cache Mode for the table. Set this to enable caching of metadata from external data source.
667    pub metadata_cache_mode: Option<MetadataCacheMode>,
668    /// Optional. ObjectMetadata is used to create Object Tables. Object Tables contain a listing of objects (with their metadata) found at the sourceUris. If ObjectMetadata is set, sourceFormat should be omitted.
669    /// Currently SIMPLE is the only supported Object Metadata type.
670    pub object_metadata: Option<ObjectMetadata>,
671}
672
673#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
674#[serde(rename_all = "camelCase")]
675pub struct Table {
676    /// Output only. The resource type.
677    pub kind: String,
678    /// Output only. A hash of the resource.
679    #[serde(default)]
680    pub etag: String,
681    /// Output only. The fully-qualified unique name of the dataset in the format projectId:datasetId.
682    /// The dataset name without the project name is given in the datasetId field. When creating a new dataset,
683    /// leave this field blank, and instead specify the datasetId field.
684    pub id: String,
685    /// Output only. A URL that can be used to access the resource again.
686    /// You can use this URL in Get or Update requests to the resource.
687    pub self_link: String,
688    /// Required. Reference describing the ID of this table.
689    pub table_reference: TableReference,
690    /// Optional. A descriptive name for the dataset.
691    pub friendly_name: Option<String>,
692    /// Optional. Optional. A user-friendly description of the dataset.
693    pub description: Option<String>,
694    /// The labels associated with this dataset.
695    /// You can use these to organize and group your datasets.
696    /// You can set this property when inserting or updating a dataset.
697    /// See Creating and Updating Dataset Labels for more information.
698    ///
699    /// An object containing a list of "key": value pairs.
700    /// Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.
701    pub labels: Option<std::collections::HashMap<String, String>>,
702    /// Optional. Describes the schema of this table.
703    pub schema: Option<TableSchema>,
704    /// If specified, configures time-based partitioning for this table.
705    pub time_partitioning: Option<TimePartitioning>,
706    /// If specified, configures range partitioning for this table.
707    pub range_partitioning: Option<RangePartitioning>,
708    /// Clustering specification for the table.
709    /// Must be specified with time-based partitioning,
710    /// data in the table will be first partitioned and subsequently clustered.
711    pub clustering: Option<Clustering>,
712    /// Optional. If set to true, queries over this table require a partition filter that can be used for partition elimination to be specified.
713    pub require_partition_filter: Option<bool>,
714    /// Output only. The size of this table in logical bytes, excluding any data in the streaming buffer.
715    #[serde(deserialize_with = "crate::http::from_str_option")]
716    #[serde(default)]
717    pub num_bytes: Option<i64>,
718    /// Output only. The number of logical bytes in the table that are considered "long-term storage".
719    #[serde(deserialize_with = "crate::http::from_str")]
720    #[serde(serialize_with = "crate::http::into_str")]
721    #[serde(default)]
722    pub num_long_term_bytes: i64,
723    /// Output only. The number of rows of data in this table, excluding any data in the streaming buffer.
724    #[serde(deserialize_with = "crate::http::from_str")]
725    #[serde(serialize_with = "crate::http::into_str")]
726    #[serde(default)]
727    pub num_rows: u64,
728    /// Output only. The time when this table was created, in milliseconds since the epoch.
729    #[serde(deserialize_with = "crate::http::from_str")]
730    #[serde(serialize_with = "crate::http::into_str")]
731    pub creation_time: i64,
732    /// Optional. The time when this table expires, in milliseconds since the epoch.
733    /// If not present, the table will persist indefinitely. Expired tables will be deleted and their storage reclaimed. The defaultTableExpirationMs property of the encapsulating dataset can be used to set a default expirationTime on newly created tables.
734    #[serde(deserialize_with = "crate::http::from_str_option")]
735    #[serde(default)]
736    pub expiration_time: Option<i64>,
737    /// Output only. The time when this table was last modified, in milliseconds since the epoch.
738    #[serde(deserialize_with = "crate::http::from_str")]
739    #[serde(serialize_with = "crate::http::into_str")]
740    pub last_modified_time: u64,
741    /// Output only. Describes the table type. The following values are supported:
742    ///
743    /// TABLE: A normal BigQuery table.
744    /// VIEW: A virtual table defined by a SQL query.
745    /// EXTERNAL: A table that references data stored in an external storage system, such as Google Cloud Storage.
746    /// MATERIALIZED_VIEW: A precomputed view defined by a SQL query.
747    /// SNAPSHOT: An immutable BigQuery table that preserves the contents of a base table at a particular time. See additional information on table snapshots.
748    /// The default value is TABLE.
749    #[serde(rename(deserialize = "type"))]
750    pub table_type: String,
751    /// Optional. The view definition.
752    pub view: Option<ViewDefinition>,
753    /// Optional. The materialized view definition.
754    pub materialized_view: Option<MaterializedViewDefinition>,
755    /// Optional. Describes the data format, location,
756    /// and other properties of a table stored outside of BigQuery.
757    /// By defining these properties, the data source can then be queried as if it were a standard BigQuery table.
758    pub external_data_configuration: Option<ExternalDataConfiguration>,
759    /// Output only. The geographic location where the table resides.
760    /// This value is inherited from the dataset.
761    #[serde(default)]
762    pub location: String,
763    /// Output only. Contains information regarding this table's streaming buffer, if one is present.
764    /// This field will be absent if the table is not being streamed to or
765    /// if there is no data in the streaming buffer.
766    pub streaming_buffer: Option<Streamingbuffer>,
767    /// Custom encryption configuration (e.g., Cloud KMS keys).
768    pub encryption_configuration: Option<EncryptionConfiguration>,
769    /// Output only. Contains information about the snapshot. This value is set via snapshot creation.
770    pub snapshot_definition: Option<SnapshotDefinition>,
771    /// Optional. Defines the default collation specification of new STRING fields in the table.
772    /// During table creation or update, if a STRING field is added to this table without explicit collation specified, then the table inherits the table default collation. A change to this field affects only fields added afterwards, and does not alter the existing fields. The following values are supported:
773    ///
774    /// 'und:ci': undetermined locale, case insensitive.
775    /// '': empty string. Default to case-sensitive behavior.
776    pub default_collation: Option<Collation>,
777    /// Output only. Contains information about the clone. This value is set via the clone operation.
778    pub clone_definition: Option<CloneDefinition>,
779    /// Optional. The maximum staleness of data that could be returned when the table (or stale MV) is queried.
780    /// Staleness encoded as a string encoding of sql IntervalValue type.
781    pub max_staleness: Option<String>,
782}