1#![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 pub allow_large_results: std::option::Option<wkt::BoolValue>,
33
34 pub clustering: std::option::Option<google_cloud_bigquery_v2::model::Clustering>,
36
37 pub connection_properties: std::vec::Vec<google_cloud_bigquery_v2::model::ConnectionProperty>,
39
40 pub create_disposition: std::string::String,
52
53 pub create_session: std::option::Option<wkt::BoolValue>,
60
61 pub default_dataset: std::option::Option<google_cloud_bigquery_v2::model::DatasetReference>,
65
66 pub destination_encryption_configuration:
68 std::option::Option<google_cloud_bigquery_v2::model::EncryptionConfiguration>,
69
70 pub destination_table: std::option::Option<google_cloud_bigquery_v2::model::TableReference>,
75
76 pub dry_run: bool,
81
82 pub external_table_definitions: std::collections::HashMap<
87 std::string::String,
88 google_cloud_bigquery_v2::model::ExternalDataConfiguration,
89 >,
90
91 pub flatten_results: std::option::Option<wkt::BoolValue>,
97
98 pub job_creation_mode: google_cloud_bigquery_v2::model::query_request::JobCreationMode,
103
104 pub job_timeout_ms: std::option::Option<i64>,
111
112 pub labels: std::collections::HashMap<std::string::String, std::string::String>,
119
120 pub location: std::string::String,
125
126 pub max_results: std::option::Option<wkt::UInt32Value>,
132
133 pub max_slots: std::option::Option<i32>,
141
142 pub maximum_bytes_billed: std::option::Option<wkt::Int64Value>,
146
147 pub parameter_mode: std::string::String,
150
151 pub priority: std::string::String,
154
155 pub query: std::string::String,
159
160 pub query_parameters: std::vec::Vec<google_cloud_bigquery_v2::model::QueryParameter>,
162
163 pub range_partitioning: std::option::Option<google_cloud_bigquery_v2::model::RangePartitioning>,
166
167 pub reservation: std::option::Option<std::string::String>,
174
175 pub schema_update_options: std::vec::Vec<std::string::String>,
188
189 pub script_options: std::option::Option<google_cloud_bigquery_v2::model::ScriptOptions>,
191
192 pub time_partitioning: std::option::Option<google_cloud_bigquery_v2::model::TimePartitioning>,
195
196 pub timeout_ms: std::option::Option<wkt::UInt32Value>,
211
212 pub use_legacy_sql: std::option::Option<wkt::BoolValue>,
218
219 pub use_query_cache: std::option::Option<wkt::BoolValue>,
223
224 pub user_defined_function_resources:
226 std::vec::Vec<google_cloud_bigquery_v2::model::UserDefinedFunctionResource>,
227
228 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 pub fn new() -> Self {
251 std::default::Default::default()
252 }
253
254 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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}