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