Skip to main content

google_cloud_bigquery/generated/
query_request.rs

1// Copyright 2026 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//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16
17#![allow(rustdoc::bare_urls)]
18#![allow(rustdoc::broken_intra_doc_links)]
19#![allow(rustdoc::invalid_html_tags)]
20#![allow(rustdoc::redundant_explicit_links)]
21
22#[allow(missing_docs)]
23#[derive(Clone, Default, PartialEq)]
24#[non_exhaustive]
25pub struct QueryRequest {
26    /// Optional. If true and query uses legacy SQL dialect, allows the query
27    /// to produce arbitrarily large result tables at a slight cost in performance.
28    /// Requires destinationTable to be set.
29    /// For GoogleSQL queries, this flag is ignored and large results are
30    /// always allowed.  However, you must still set destinationTable when result
31    /// size exceeds the allowed maximum response size.
32    pub allow_large_results: std::option::Option<wkt::BoolValue>,
33
34    /// Clustering specification for the destination table.
35    pub clustering: std::option::Option<google_cloud_bigquery_v2::model::Clustering>,
36
37    /// Optional. Connection properties which can modify the query behavior.
38    pub connection_properties: std::vec::Vec<google_cloud_bigquery_v2::model::ConnectionProperty>,
39
40    /// Optional. Specifies whether the job is allowed to create new tables.
41    /// The following values are supported:
42    ///
43    /// * CREATE_IF_NEEDED: If the table does not exist, BigQuery creates the
44    ///   table.
45    /// * CREATE_NEVER: The table must already exist. If it does not,
46    ///   a 'notFound' error is returned in the job result.
47    ///
48    /// The default value is CREATE_IF_NEEDED.
49    /// Creation, truncation and append actions occur as one atomic update
50    /// upon job completion.
51    pub create_disposition: std::string::String,
52
53    /// Optional. If true, creates a new session using a randomly generated
54    /// session_id. If false, runs query with an existing session_id passed in
55    /// ConnectionProperty, otherwise runs query in non-session mode.
56    ///
57    /// The session location will be set to QueryRequest.location if it is present,
58    /// otherwise it's set to the default location based on existing routing logic.
59    pub create_session: std::option::Option<wkt::BoolValue>,
60
61    /// Optional. Specifies the default datasetId and projectId to assume for any
62    /// unqualified table names in the query. If not set, all table names in the
63    /// query string must be qualified in the format 'datasetId.tableId'.
64    pub default_dataset: std::option::Option<google_cloud_bigquery_v2::model::DatasetReference>,
65
66    /// Optional. Custom encryption configuration (e.g., Cloud KMS keys)
67    pub destination_encryption_configuration:
68        std::option::Option<google_cloud_bigquery_v2::model::EncryptionConfiguration>,
69
70    /// Optional. Describes the table where the query results should be stored.
71    /// This property must be set for large results that exceed the maximum
72    /// response size.  For queries that produce anonymous (cached) results, this
73    /// field will be populated by BigQuery.
74    pub destination_table: std::option::Option<google_cloud_bigquery_v2::model::TableReference>,
75
76    /// Optional. If set to true, BigQuery doesn't run the job. Instead, if the
77    /// query is valid, BigQuery returns statistics about the job such as how many
78    /// bytes would be processed. If the query is invalid, an error returns. The
79    /// default value is false.
80    pub dry_run: bool,
81
82    /// Optional. You can specify external table definitions, which operate as
83    /// ephemeral tables that can be queried.  These definitions are configured
84    /// using a JSON map, where the string key represents the table identifier, and
85    /// the value is the corresponding external data configuration object.
86    pub external_table_definitions: std::collections::HashMap<
87        std::string::String,
88        google_cloud_bigquery_v2::model::ExternalDataConfiguration,
89    >,
90
91    /// Optional. If true and query uses legacy SQL dialect, flattens all nested
92    /// and repeated fields in the query results.
93    /// allowLargeResults must be true if this is set to false.
94    /// For GoogleSQL queries, this flag is ignored and results are never
95    /// flattened.
96    pub flatten_results: std::option::Option<wkt::BoolValue>,
97
98    /// Optional. If not set, jobs are always required.
99    ///
100    /// If set, the query request will follow the behavior described
101    /// JobCreationMode.
102    pub job_creation_mode: google_cloud_bigquery_v2::model::query_request::JobCreationMode,
103
104    /// Optional. Job timeout in milliseconds. If this time limit is exceeded,
105    /// BigQuery will attempt to stop a longer job, but may not always succeed in
106    /// canceling it before the job completes. For example, a job that takes more
107    /// than 60 seconds to complete has a better chance of being stopped than a job
108    /// that takes 10 seconds to complete. This timeout applies to the query even
109    /// if a job does not need to be created.
110    pub job_timeout_ms: std::option::Option<i64>,
111
112    /// Optional. The labels associated with this query.
113    /// Labels can be used to organize and group query jobs.
114    /// Label keys and values can be no longer than 63 characters, can only contain
115    /// lowercase letters, numeric characters, underscores and dashes.
116    /// International characters are allowed. Label keys must start with a letter
117    /// and each label in the list must have a different key.
118    pub labels: std::collections::HashMap<std::string::String, std::string::String>,
119
120    /// The geographic location where the job should run.
121    /// For more information, see how to
122    /// [specify
123    /// locations](https://cloud.google.com/bigquery/docs/locations#specify_locations).
124    pub location: std::string::String,
125
126    /// Optional. The maximum number of rows of data to return per page of
127    /// results. Setting this flag to a small value such as 1000 and then paging
128    /// through results might improve reliability when the query result set is
129    /// large. In addition to this limit, responses are also limited to 10 MB. By
130    /// default, there is no maximum row count, and only the byte limit applies.
131    pub max_results: std::option::Option<wkt::UInt32Value>,
132
133    /// Optional. A target limit on the rate of slot consumption by this query. If
134    /// set to a value > 0, BigQuery will attempt to limit the rate of slot
135    /// consumption by this query to keep it below the configured limit, even if
136    /// the query is eligible for more slots based on fair scheduling. The unused
137    /// slots will be available for other jobs and queries to use.
138    ///
139    /// Note: This feature is not yet generally available.
140    pub max_slots: std::option::Option<i32>,
141
142    /// Optional. Limits the bytes billed for this query. Queries with
143    /// bytes billed above this limit will fail (without incurring a charge).
144    /// If unspecified, the project default is used.
145    pub maximum_bytes_billed: std::option::Option<wkt::Int64Value>,
146
147    /// GoogleSQL only. Set to POSITIONAL to use positional (?) query parameters
148    /// or to NAMED to use named (@myparam) query parameters in this query.
149    pub parameter_mode: std::string::String,
150
151    /// Optional. Specifies a priority for the query. Possible values include
152    /// INTERACTIVE and BATCH. The default value is INTERACTIVE.
153    pub priority: std::string::String,
154
155    /// Required. A query string to execute, using Google Standard SQL or legacy
156    /// SQL syntax. Example: "SELECT COUNT(f1) FROM
157    /// myProjectId.myDatasetId.myTableId".
158    pub query: std::string::String,
159
160    /// Query parameters for GoogleSQL queries.
161    pub query_parameters: std::vec::Vec<google_cloud_bigquery_v2::model::QueryParameter>,
162
163    /// Range partitioning specification for the destination table.
164    /// Only one of timePartitioning and rangePartitioning should be specified.
165    pub range_partitioning: std::option::Option<google_cloud_bigquery_v2::model::RangePartitioning>,
166
167    /// Optional. The reservation that jobs.query request would use. User can
168    /// specify a reservation to execute the job.query. The expected format is
169    /// `projects/{project}/locations/{location}/reservations/{reservation}`.
170    /// Forces the query to use on-demand billing when set to `none`.
171    /// This requires the project or organization to have
172    /// `reservation_override_mode` set to `ALLOW_ANY_OVERRIDE`.
173    pub reservation: std::option::Option<std::string::String>,
174
175    /// Allows the schema of the destination table to be updated as a side effect
176    /// of the query job. Schema update options are supported in three cases:
177    /// when writeDisposition is WRITE_APPEND;
178    /// when writeDisposition is WRITE_TRUNCATE_DATA;
179    /// when writeDisposition is WRITE_TRUNCATE and the destination table is a
180    /// partition of a table, specified by partition decorators. For normal tables,
181    /// WRITE_TRUNCATE will always overwrite the schema.
182    /// One or more of the following values are specified:
183    ///
184    /// * ALLOW_FIELD_ADDITION: allow adding a nullable field to the schema.
185    /// * ALLOW_FIELD_RELAXATION: allow relaxing a required field in the original
186    ///   schema to nullable.
187    pub schema_update_options: std::vec::Vec<std::string::String>,
188
189    /// Options controlling the execution of scripts.
190    pub script_options: std::option::Option<google_cloud_bigquery_v2::model::ScriptOptions>,
191
192    /// Time-based partitioning specification for the destination table. Only one
193    /// of timePartitioning and rangePartitioning should be specified.
194    pub time_partitioning: std::option::Option<google_cloud_bigquery_v2::model::TimePartitioning>,
195
196    /// Optional. Optional: Specifies the maximum amount of time, in milliseconds,
197    /// that the client is willing to wait for the query to complete. By default,
198    /// this limit is 10 seconds (10,000 milliseconds). If the query is complete,
199    /// the jobComplete field in the response is true. If the query has not yet
200    /// completed, jobComplete is false.
201    ///
202    /// You can request a longer timeout period in the timeoutMs field.  However,
203    /// the call is not guaranteed to wait for the specified timeout; it typically
204    /// returns after around 200 seconds (200,000 milliseconds), even if the query
205    /// is not complete.
206    ///
207    /// If jobComplete is false, you can continue to wait for the query to complete
208    /// by calling the getQueryResults method until the jobComplete field in the
209    /// getQueryResults response is true.
210    pub timeout_ms: std::option::Option<wkt::UInt32Value>,
211
212    /// Specifies whether to use BigQuery's legacy SQL dialect for this query. The
213    /// default value is true. If set to false, the query uses BigQuery's
214    /// [GoogleSQL](https://docs.cloud.google.com/bigquery/docs/introduction-sql).
215    /// When useLegacySql is set to false, the value of flattenResults is ignored;
216    /// query will be run as if flattenResults is false.
217    pub use_legacy_sql: std::option::Option<wkt::BoolValue>,
218
219    /// Optional. Whether to look for the result in the query cache. The query
220    /// cache is a best-effort cache that will be flushed whenever tables in the
221    /// query are modified. The default value is true.
222    pub use_query_cache: std::option::Option<wkt::BoolValue>,
223
224    /// Describes user-defined function resources used in the query.
225    pub user_defined_function_resources:
226        std::vec::Vec<google_cloud_bigquery_v2::model::UserDefinedFunctionResource>,
227
228    /// Optional. Specifies the action that occurs if the destination table
229    /// already exists. The following values are supported:
230    ///
231    /// * WRITE_TRUNCATE: If the table already exists, BigQuery overwrites the
232    ///   data, removes the constraints, and uses the schema from the query result.
233    /// * WRITE_TRUNCATE_DATA: If the table already exists, BigQuery overwrites the
234    ///   data, but keeps the constraints and schema of the existing table.
235    /// * WRITE_APPEND: If the table already exists, BigQuery appends the data to
236    ///   the table.
237    /// * WRITE_EMPTY: If the table already exists and contains data, a 'duplicate'
238    ///   error is returned in the job result.
239    ///
240    /// The default value is WRITE_EMPTY. Each action is atomic and only occurs if
241    /// BigQuery is able to complete the job successfully. Creation, truncation and
242    /// append actions occur as one atomic update upon job completion.
243    pub write_disposition: std::string::String,
244
245    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
246}
247
248impl QueryRequest {
249    /// Creates a new default instance.
250    pub fn new() -> Self {
251        std::default::Default::default()
252    }
253
254    /// Sets the value of [allow_large_results][crate::model_ext::QueryRequest::allow_large_results].
255    pub fn set_allow_large_results<T>(mut self, v: T) -> Self
256    where
257        T: std::convert::Into<wkt::BoolValue>,
258    {
259        self.allow_large_results = std::option::Option::Some(v.into());
260        self
261    }
262
263    /// Sets or clears the value of [allow_large_results][crate::model_ext::QueryRequest::allow_large_results].
264    pub fn set_or_clear_allow_large_results<T>(mut self, v: std::option::Option<T>) -> Self
265    where
266        T: std::convert::Into<wkt::BoolValue>,
267    {
268        self.allow_large_results = v.map(|x| x.into());
269        self
270    }
271
272    /// Sets the value of [clustering][crate::model_ext::QueryRequest::clustering].
273    pub fn set_clustering<T>(mut self, v: T) -> Self
274    where
275        T: std::convert::Into<google_cloud_bigquery_v2::model::Clustering>,
276    {
277        self.clustering = std::option::Option::Some(v.into());
278        self
279    }
280
281    /// Sets or clears the value of [clustering][crate::model_ext::QueryRequest::clustering].
282    pub fn set_or_clear_clustering<T>(mut self, v: std::option::Option<T>) -> Self
283    where
284        T: std::convert::Into<google_cloud_bigquery_v2::model::Clustering>,
285    {
286        self.clustering = v.map(|x| x.into());
287        self
288    }
289
290    /// Sets the value of [connection_properties][crate::model_ext::QueryRequest::connection_properties].
291    pub fn set_connection_properties<T, V>(mut self, v: T) -> Self
292    where
293        T: std::iter::IntoIterator<Item = V>,
294        V: std::convert::Into<google_cloud_bigquery_v2::model::ConnectionProperty>,
295    {
296        use std::iter::Iterator;
297        self.connection_properties = v.into_iter().map(|i| i.into()).collect();
298        self
299    }
300
301    /// Sets the value of [create_disposition][crate::model_ext::QueryRequest::create_disposition].
302    pub fn set_create_disposition<T: std::convert::Into<std::string::String>>(
303        mut self,
304        v: T,
305    ) -> Self {
306        self.create_disposition = v.into();
307        self
308    }
309
310    /// Sets the value of [create_session][crate::model_ext::QueryRequest::create_session].
311    pub fn set_create_session<T>(mut self, v: T) -> Self
312    where
313        T: std::convert::Into<wkt::BoolValue>,
314    {
315        self.create_session = std::option::Option::Some(v.into());
316        self
317    }
318
319    /// Sets or clears the value of [create_session][crate::model_ext::QueryRequest::create_session].
320    pub fn set_or_clear_create_session<T>(mut self, v: std::option::Option<T>) -> Self
321    where
322        T: std::convert::Into<wkt::BoolValue>,
323    {
324        self.create_session = v.map(|x| x.into());
325        self
326    }
327
328    /// Sets the value of [default_dataset][crate::model_ext::QueryRequest::default_dataset].
329    pub fn set_default_dataset<T>(mut self, v: T) -> Self
330    where
331        T: std::convert::Into<google_cloud_bigquery_v2::model::DatasetReference>,
332    {
333        self.default_dataset = std::option::Option::Some(v.into());
334        self
335    }
336
337    /// Sets or clears the value of [default_dataset][crate::model_ext::QueryRequest::default_dataset].
338    pub fn set_or_clear_default_dataset<T>(mut self, v: std::option::Option<T>) -> Self
339    where
340        T: std::convert::Into<google_cloud_bigquery_v2::model::DatasetReference>,
341    {
342        self.default_dataset = v.map(|x| x.into());
343        self
344    }
345
346    /// Sets the value of [destination_encryption_configuration][crate::model_ext::QueryRequest::destination_encryption_configuration].
347    pub fn set_destination_encryption_configuration<T>(mut self, v: T) -> Self
348    where
349        T: std::convert::Into<google_cloud_bigquery_v2::model::EncryptionConfiguration>,
350    {
351        self.destination_encryption_configuration = std::option::Option::Some(v.into());
352        self
353    }
354
355    /// Sets or clears the value of [destination_encryption_configuration][crate::model_ext::QueryRequest::destination_encryption_configuration].
356    pub fn set_or_clear_destination_encryption_configuration<T>(
357        mut self,
358        v: std::option::Option<T>,
359    ) -> Self
360    where
361        T: std::convert::Into<google_cloud_bigquery_v2::model::EncryptionConfiguration>,
362    {
363        self.destination_encryption_configuration = v.map(|x| x.into());
364        self
365    }
366
367    /// Sets the value of [destination_table][crate::model_ext::QueryRequest::destination_table].
368    pub fn set_destination_table<T>(mut self, v: T) -> Self
369    where
370        T: std::convert::Into<google_cloud_bigquery_v2::model::TableReference>,
371    {
372        self.destination_table = std::option::Option::Some(v.into());
373        self
374    }
375
376    /// Sets or clears the value of [destination_table][crate::model_ext::QueryRequest::destination_table].
377    pub fn set_or_clear_destination_table<T>(mut self, v: std::option::Option<T>) -> Self
378    where
379        T: std::convert::Into<google_cloud_bigquery_v2::model::TableReference>,
380    {
381        self.destination_table = v.map(|x| x.into());
382        self
383    }
384
385    /// Sets the value of [dry_run][crate::model_ext::QueryRequest::dry_run].
386    pub fn set_dry_run<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
387        self.dry_run = v.into();
388        self
389    }
390
391    /// Sets the value of [external_table_definitions][crate::model_ext::QueryRequest::external_table_definitions].
392    pub fn set_external_table_definitions<T, K, V>(mut self, v: T) -> Self
393    where
394        T: std::iter::IntoIterator<Item = (K, V)>,
395        K: std::convert::Into<std::string::String>,
396        V: std::convert::Into<google_cloud_bigquery_v2::model::ExternalDataConfiguration>,
397    {
398        use std::iter::Iterator;
399        self.external_table_definitions =
400            v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
401        self
402    }
403
404    /// Sets the value of [flatten_results][crate::model_ext::QueryRequest::flatten_results].
405    pub fn set_flatten_results<T>(mut self, v: T) -> Self
406    where
407        T: std::convert::Into<wkt::BoolValue>,
408    {
409        self.flatten_results = std::option::Option::Some(v.into());
410        self
411    }
412
413    /// Sets or clears the value of [flatten_results][crate::model_ext::QueryRequest::flatten_results].
414    pub fn set_or_clear_flatten_results<T>(mut self, v: std::option::Option<T>) -> Self
415    where
416        T: std::convert::Into<wkt::BoolValue>,
417    {
418        self.flatten_results = v.map(|x| x.into());
419        self
420    }
421
422    /// Sets the value of [job_creation_mode][crate::model_ext::QueryRequest::job_creation_mode].
423    pub fn set_job_creation_mode<
424        T: std::convert::Into<google_cloud_bigquery_v2::model::query_request::JobCreationMode>,
425    >(
426        mut self,
427        v: T,
428    ) -> Self {
429        self.job_creation_mode = v.into();
430        self
431    }
432
433    /// Sets the value of [job_timeout_ms][crate::model_ext::QueryRequest::job_timeout_ms].
434    pub fn set_job_timeout_ms<T>(mut self, v: T) -> Self
435    where
436        T: std::convert::Into<i64>,
437    {
438        self.job_timeout_ms = std::option::Option::Some(v.into());
439        self
440    }
441
442    /// Sets or clears the value of [job_timeout_ms][crate::model_ext::QueryRequest::job_timeout_ms].
443    pub fn set_or_clear_job_timeout_ms<T>(mut self, v: std::option::Option<T>) -> Self
444    where
445        T: std::convert::Into<i64>,
446    {
447        self.job_timeout_ms = v.map(|x| x.into());
448        self
449    }
450
451    /// Sets the value of [labels][crate::model_ext::QueryRequest::labels].
452    pub fn set_labels<T, K, V>(mut self, v: T) -> Self
453    where
454        T: std::iter::IntoIterator<Item = (K, V)>,
455        K: std::convert::Into<std::string::String>,
456        V: std::convert::Into<std::string::String>,
457    {
458        use std::iter::Iterator;
459        self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
460        self
461    }
462
463    /// Sets the value of [location][crate::model_ext::QueryRequest::location].
464    pub fn set_location<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
465        self.location = v.into();
466        self
467    }
468
469    /// Sets the value of [max_results][crate::model_ext::QueryRequest::max_results].
470    pub fn set_max_results<T>(mut self, v: T) -> Self
471    where
472        T: std::convert::Into<wkt::UInt32Value>,
473    {
474        self.max_results = std::option::Option::Some(v.into());
475        self
476    }
477
478    /// Sets or clears the value of [max_results][crate::model_ext::QueryRequest::max_results].
479    pub fn set_or_clear_max_results<T>(mut self, v: std::option::Option<T>) -> Self
480    where
481        T: std::convert::Into<wkt::UInt32Value>,
482    {
483        self.max_results = v.map(|x| x.into());
484        self
485    }
486
487    /// Sets the value of [max_slots][crate::model_ext::QueryRequest::max_slots].
488    pub fn set_max_slots<T>(mut self, v: T) -> Self
489    where
490        T: std::convert::Into<i32>,
491    {
492        self.max_slots = std::option::Option::Some(v.into());
493        self
494    }
495
496    /// Sets or clears the value of [max_slots][crate::model_ext::QueryRequest::max_slots].
497    pub fn set_or_clear_max_slots<T>(mut self, v: std::option::Option<T>) -> Self
498    where
499        T: std::convert::Into<i32>,
500    {
501        self.max_slots = v.map(|x| x.into());
502        self
503    }
504
505    /// Sets the value of [maximum_bytes_billed][crate::model_ext::QueryRequest::maximum_bytes_billed].
506    pub fn set_maximum_bytes_billed<T>(mut self, v: T) -> Self
507    where
508        T: std::convert::Into<wkt::Int64Value>,
509    {
510        self.maximum_bytes_billed = std::option::Option::Some(v.into());
511        self
512    }
513
514    /// Sets or clears the value of [maximum_bytes_billed][crate::model_ext::QueryRequest::maximum_bytes_billed].
515    pub fn set_or_clear_maximum_bytes_billed<T>(mut self, v: std::option::Option<T>) -> Self
516    where
517        T: std::convert::Into<wkt::Int64Value>,
518    {
519        self.maximum_bytes_billed = v.map(|x| x.into());
520        self
521    }
522
523    /// Sets the value of [parameter_mode][crate::model_ext::QueryRequest::parameter_mode].
524    pub fn set_parameter_mode<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
525        self.parameter_mode = v.into();
526        self
527    }
528
529    /// Sets the value of [priority][crate::model_ext::QueryRequest::priority].
530    pub fn set_priority<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
531        self.priority = v.into();
532        self
533    }
534
535    /// Sets the value of [query][crate::model_ext::QueryRequest::query].
536    pub fn set_query<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
537        self.query = v.into();
538        self
539    }
540
541    /// Sets the value of [query_parameters][crate::model_ext::QueryRequest::query_parameters].
542    pub fn set_query_parameters<T, V>(mut self, v: T) -> Self
543    where
544        T: std::iter::IntoIterator<Item = V>,
545        V: std::convert::Into<google_cloud_bigquery_v2::model::QueryParameter>,
546    {
547        use std::iter::Iterator;
548        self.query_parameters = v.into_iter().map(|i| i.into()).collect();
549        self
550    }
551
552    /// Sets the value of [range_partitioning][crate::model_ext::QueryRequest::range_partitioning].
553    pub fn set_range_partitioning<T>(mut self, v: T) -> Self
554    where
555        T: std::convert::Into<google_cloud_bigquery_v2::model::RangePartitioning>,
556    {
557        self.range_partitioning = std::option::Option::Some(v.into());
558        self
559    }
560
561    /// Sets or clears the value of [range_partitioning][crate::model_ext::QueryRequest::range_partitioning].
562    pub fn set_or_clear_range_partitioning<T>(mut self, v: std::option::Option<T>) -> Self
563    where
564        T: std::convert::Into<google_cloud_bigquery_v2::model::RangePartitioning>,
565    {
566        self.range_partitioning = v.map(|x| x.into());
567        self
568    }
569
570    /// Sets the value of [reservation][crate::model_ext::QueryRequest::reservation].
571    pub fn set_reservation<T>(mut self, v: T) -> Self
572    where
573        T: std::convert::Into<std::string::String>,
574    {
575        self.reservation = std::option::Option::Some(v.into());
576        self
577    }
578
579    /// Sets or clears the value of [reservation][crate::model_ext::QueryRequest::reservation].
580    pub fn set_or_clear_reservation<T>(mut self, v: std::option::Option<T>) -> Self
581    where
582        T: std::convert::Into<std::string::String>,
583    {
584        self.reservation = v.map(|x| x.into());
585        self
586    }
587
588    /// Sets the value of [schema_update_options][crate::model_ext::QueryRequest::schema_update_options].
589    pub fn set_schema_update_options<T, V>(mut self, v: T) -> Self
590    where
591        T: std::iter::IntoIterator<Item = V>,
592        V: std::convert::Into<std::string::String>,
593    {
594        use std::iter::Iterator;
595        self.schema_update_options = v.into_iter().map(|i| i.into()).collect();
596        self
597    }
598
599    /// Sets the value of [script_options][crate::model_ext::QueryRequest::script_options].
600    pub fn set_script_options<T>(mut self, v: T) -> Self
601    where
602        T: std::convert::Into<google_cloud_bigquery_v2::model::ScriptOptions>,
603    {
604        self.script_options = std::option::Option::Some(v.into());
605        self
606    }
607
608    /// Sets or clears the value of [script_options][crate::model_ext::QueryRequest::script_options].
609    pub fn set_or_clear_script_options<T>(mut self, v: std::option::Option<T>) -> Self
610    where
611        T: std::convert::Into<google_cloud_bigquery_v2::model::ScriptOptions>,
612    {
613        self.script_options = v.map(|x| x.into());
614        self
615    }
616
617    /// Sets the value of [time_partitioning][crate::model_ext::QueryRequest::time_partitioning].
618    pub fn set_time_partitioning<T>(mut self, v: T) -> Self
619    where
620        T: std::convert::Into<google_cloud_bigquery_v2::model::TimePartitioning>,
621    {
622        self.time_partitioning = std::option::Option::Some(v.into());
623        self
624    }
625
626    /// Sets or clears the value of [time_partitioning][crate::model_ext::QueryRequest::time_partitioning].
627    pub fn set_or_clear_time_partitioning<T>(mut self, v: std::option::Option<T>) -> Self
628    where
629        T: std::convert::Into<google_cloud_bigquery_v2::model::TimePartitioning>,
630    {
631        self.time_partitioning = v.map(|x| x.into());
632        self
633    }
634
635    /// Sets the value of [timeout_ms][crate::model_ext::QueryRequest::timeout_ms].
636    pub fn set_timeout_ms<T>(mut self, v: T) -> Self
637    where
638        T: std::convert::Into<wkt::UInt32Value>,
639    {
640        self.timeout_ms = std::option::Option::Some(v.into());
641        self
642    }
643
644    /// Sets or clears the value of [timeout_ms][crate::model_ext::QueryRequest::timeout_ms].
645    pub fn set_or_clear_timeout_ms<T>(mut self, v: std::option::Option<T>) -> Self
646    where
647        T: std::convert::Into<wkt::UInt32Value>,
648    {
649        self.timeout_ms = v.map(|x| x.into());
650        self
651    }
652
653    /// Sets the value of [use_legacy_sql][crate::model_ext::QueryRequest::use_legacy_sql].
654    pub fn set_use_legacy_sql<T>(mut self, v: T) -> Self
655    where
656        T: std::convert::Into<wkt::BoolValue>,
657    {
658        self.use_legacy_sql = std::option::Option::Some(v.into());
659        self
660    }
661
662    /// Sets or clears the value of [use_legacy_sql][crate::model_ext::QueryRequest::use_legacy_sql].
663    pub fn set_or_clear_use_legacy_sql<T>(mut self, v: std::option::Option<T>) -> Self
664    where
665        T: std::convert::Into<wkt::BoolValue>,
666    {
667        self.use_legacy_sql = v.map(|x| x.into());
668        self
669    }
670
671    /// Sets the value of [use_query_cache][crate::model_ext::QueryRequest::use_query_cache].
672    pub fn set_use_query_cache<T>(mut self, v: T) -> Self
673    where
674        T: std::convert::Into<wkt::BoolValue>,
675    {
676        self.use_query_cache = std::option::Option::Some(v.into());
677        self
678    }
679
680    /// Sets or clears the value of [use_query_cache][crate::model_ext::QueryRequest::use_query_cache].
681    pub fn set_or_clear_use_query_cache<T>(mut self, v: std::option::Option<T>) -> Self
682    where
683        T: std::convert::Into<wkt::BoolValue>,
684    {
685        self.use_query_cache = v.map(|x| x.into());
686        self
687    }
688
689    /// Sets the value of [user_defined_function_resources][crate::model_ext::QueryRequest::user_defined_function_resources].
690    pub fn set_user_defined_function_resources<T, V>(mut self, v: T) -> Self
691    where
692        T: std::iter::IntoIterator<Item = V>,
693        V: std::convert::Into<google_cloud_bigquery_v2::model::UserDefinedFunctionResource>,
694    {
695        use std::iter::Iterator;
696        self.user_defined_function_resources = v.into_iter().map(|i| i.into()).collect();
697        self
698    }
699
700    /// Sets the value of [write_disposition][crate::model_ext::QueryRequest::write_disposition].
701    pub fn set_write_disposition<T: std::convert::Into<std::string::String>>(
702        mut self,
703        v: T,
704    ) -> Self {
705        self.write_disposition = v.into();
706        self
707    }
708}
709
710mod debug {
711
712    impl std::fmt::Debug for super::QueryRequest {
713        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
714            let mut debug_struct = f.debug_struct("QueryRequest");
715            debug_struct.field("allow_large_results", &self.allow_large_results);
716            debug_struct.field("clustering", &self.clustering);
717            debug_struct.field("connection_properties", &self.connection_properties);
718            debug_struct.field("create_disposition", &self.create_disposition);
719            debug_struct.field("create_session", &self.create_session);
720            debug_struct.field("default_dataset", &self.default_dataset);
721            debug_struct.field(
722                "destination_encryption_configuration",
723                &self.destination_encryption_configuration,
724            );
725            debug_struct.field("destination_table", &self.destination_table);
726            debug_struct.field("dry_run", &self.dry_run);
727            debug_struct.field(
728                "external_table_definitions",
729                &self.external_table_definitions,
730            );
731            debug_struct.field("flatten_results", &self.flatten_results);
732            debug_struct.field("job_creation_mode", &self.job_creation_mode);
733            debug_struct.field("job_timeout_ms", &self.job_timeout_ms);
734            debug_struct.field("labels", &self.labels);
735            debug_struct.field("location", &self.location);
736            debug_struct.field("max_results", &self.max_results);
737            debug_struct.field("max_slots", &self.max_slots);
738            debug_struct.field("maximum_bytes_billed", &self.maximum_bytes_billed);
739            debug_struct.field("parameter_mode", &self.parameter_mode);
740            debug_struct.field("priority", &self.priority);
741            debug_struct.field("query", &self.query);
742            debug_struct.field("query_parameters", &self.query_parameters);
743            debug_struct.field("range_partitioning", &self.range_partitioning);
744            debug_struct.field("reservation", &self.reservation);
745            debug_struct.field("schema_update_options", &self.schema_update_options);
746            debug_struct.field("script_options", &self.script_options);
747            debug_struct.field("time_partitioning", &self.time_partitioning);
748            debug_struct.field("timeout_ms", &self.timeout_ms);
749            debug_struct.field("use_legacy_sql", &self.use_legacy_sql);
750            debug_struct.field("use_query_cache", &self.use_query_cache);
751            debug_struct.field(
752                "user_defined_function_resources",
753                &self.user_defined_function_resources,
754            );
755            debug_struct.field("write_disposition", &self.write_disposition);
756            if !self._unknown_fields.is_empty() {
757                debug_struct.field("_unknown_fields", &self._unknown_fields);
758            }
759            debug_struct.finish()
760        }
761    }
762}
763
764impl QueryRequest {
765    #[allow(clippy::nonminimal_bool)]
766    pub(crate) fn force_job_path(&self) -> bool {
767        false
768            || !wkt::internal::is_default(&self.allow_large_results)
769            || !wkt::internal::is_default(&self.clustering)
770            || !wkt::internal::is_default(&self.create_disposition)
771            || !wkt::internal::is_default(&self.destination_table)
772            || !wkt::internal::is_default(&self.external_table_definitions)
773            || !wkt::internal::is_default(&self.flatten_results)
774            || !wkt::internal::is_default(&self.priority)
775            || !wkt::internal::is_default(&self.range_partitioning)
776            || !wkt::internal::is_default(&self.schema_update_options)
777            || !wkt::internal::is_default(&self.script_options)
778            || !wkt::internal::is_default(&self.time_partitioning)
779            || !wkt::internal::is_default(&self.user_defined_function_resources)
780            || !wkt::internal::is_default(&self.write_disposition)
781    }
782}
783
784impl std::convert::From<QueryRequest> for google_cloud_bigquery_v2::model::QueryRequest {
785    fn from(req: QueryRequest) -> Self {
786        let mut out = Self::default();
787        out.connection_properties = req.connection_properties;
788        out.create_session = req.create_session;
789        out.default_dataset = req.default_dataset;
790        out.destination_encryption_configuration = req.destination_encryption_configuration;
791        out.dry_run = req.dry_run;
792        out.job_creation_mode = req.job_creation_mode;
793        out.job_timeout_ms = req.job_timeout_ms;
794        out.labels = req.labels;
795        out.location = req.location;
796        out.max_results = req.max_results;
797        out.max_slots = req.max_slots;
798        out.maximum_bytes_billed = req.maximum_bytes_billed;
799        out.parameter_mode = req.parameter_mode;
800        out.query = req.query;
801        out.query_parameters = req.query_parameters;
802        out.reservation = req.reservation;
803        out.timeout_ms = req.timeout_ms;
804        out.use_legacy_sql = req.use_legacy_sql;
805        out.use_query_cache = req.use_query_cache;
806        out
807    }
808}
809
810impl std::convert::From<QueryRequest> for google_cloud_bigquery_v2::model::JobConfigurationQuery {
811    fn from(req: QueryRequest) -> Self {
812        let mut out = Self::default();
813        out.allow_large_results = req.allow_large_results;
814        out.clustering = req.clustering;
815        out.connection_properties = req.connection_properties;
816        out.create_disposition = req.create_disposition;
817        out.create_session = req.create_session;
818        out.default_dataset = req.default_dataset;
819        out.destination_encryption_configuration = req.destination_encryption_configuration;
820        out.destination_table = req.destination_table;
821        out.external_table_definitions = req.external_table_definitions;
822        out.flatten_results = req.flatten_results;
823        out.maximum_bytes_billed = req.maximum_bytes_billed;
824        out.parameter_mode = req.parameter_mode;
825        out.priority = req.priority;
826        out.query = req.query;
827        out.query_parameters = req.query_parameters;
828        out.range_partitioning = req.range_partitioning;
829        out.schema_update_options = req.schema_update_options;
830        out.script_options = req.script_options;
831        out.time_partitioning = req.time_partitioning;
832        out.use_legacy_sql = req.use_legacy_sql;
833        out.use_query_cache = req.use_query_cache;
834        out.user_defined_function_resources = req.user_defined_function_resources;
835        out.write_disposition = req.write_disposition;
836        out
837    }
838}
839
840impl std::convert::From<QueryRequest> for google_cloud_bigquery_v2::model::JobConfiguration {
841    #[allow(clippy::useless_conversion)]
842    fn from(req: QueryRequest) -> Self {
843        let mut query = google_cloud_bigquery_v2::model::JobConfigurationQuery::default();
844        query.allow_large_results = req.allow_large_results;
845        query.clustering = req.clustering;
846        query.connection_properties = req.connection_properties;
847        query.create_disposition = req.create_disposition;
848        query.create_session = req.create_session;
849        query.default_dataset = req.default_dataset;
850        query.destination_encryption_configuration = req.destination_encryption_configuration;
851        query.destination_table = req.destination_table;
852        query.external_table_definitions = req.external_table_definitions;
853        query.flatten_results = req.flatten_results;
854        query.maximum_bytes_billed = req.maximum_bytes_billed;
855        query.parameter_mode = req.parameter_mode;
856        query.priority = req.priority;
857        query.query = req.query;
858        query.query_parameters = req.query_parameters;
859        query.range_partitioning = req.range_partitioning;
860        query.schema_update_options = req.schema_update_options;
861        query.script_options = req.script_options;
862        query.time_partitioning = req.time_partitioning;
863        query.use_legacy_sql = req.use_legacy_sql;
864        query.use_query_cache = req.use_query_cache;
865        query.user_defined_function_resources = req.user_defined_function_resources;
866        query.write_disposition = req.write_disposition;
867        let mut out = Self::default();
868        out.query = Some(query);
869        out.dry_run = req.dry_run.into();
870        out.job_timeout_ms = req.job_timeout_ms.into();
871        out.labels = req.labels.into();
872        out.max_slots = req.max_slots.into();
873        out.reservation = req.reservation.into();
874        out
875    }
876}