google-cloud-bigquery 0.16.1-preview

Google Cloud Client Libraries for Rust - BigQuery
Documentation
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
// 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 QueryMetadata {
    /// Whether the query result was fetched from the query cache.
    pub cache_hit: std::option::Option<wkt::BoolValue>,

    /// Required. Describes the job configuration.
    pub configuration: std::option::Option<google_cloud_bigquery_v2::model::JobConfiguration>,

    /// Output only. Creation time of this query, in milliseconds since the epoch.
    /// This field will be present on all queries.
    pub creation_time: std::option::Option<i64>,

    /// Output only. Detailed statistics for DML statements INSERT, UPDATE, DELETE,
    /// MERGE or TRUNCATE.
    pub dml_stats: std::option::Option<google_cloud_bigquery_v2::model::DmlStats>,

    /// Output only. End time of this query, in milliseconds since the epoch. This
    /// field will be present whenever a query job is in the DONE state.
    pub end_time: std::option::Option<i64>,

    /// Output only. The first errors or warnings encountered during the running of
    /// the job. The final message includes the number of errors that caused the
    /// process to stop. Errors here do not necessarily mean that the job has
    /// completed or was unsuccessful. For more information about error messages,
    /// see [Error
    /// messages](https://cloud.google.com/bigquery/docs/error-messages).
    pub errors: std::vec::Vec<google_cloud_bigquery_v2::model::ErrorProto>,

    /// Output only. A hash of this resource.
    pub etag: std::string::String,

    /// Output only. Opaque ID field of the job.
    pub id: std::string::String,

    /// Whether the query has completed or not. If rows or totalRows are present,
    /// this will always be true. If this is false, totalRows will not be
    /// available.
    pub job_complete: std::option::Option<wkt::BoolValue>,

    /// Output only. The reason why a Job was created.
    pub job_creation_reason:
        std::option::Option<google_cloud_bigquery_v2::model::JobCreationReason>,

    /// Optional. Reference describing the unique-per-user name of the job.
    pub job_reference: std::option::Option<google_cloud_bigquery_v2::model::JobReference>,

    /// Output only. The type of the resource.
    pub kind: std::string::String,

    /// Output only. The geographic location of the query.
    ///
    /// For more information about BigQuery locations, see:
    /// <https://cloud.google.com/bigquery/docs/locations>
    pub location: std::string::String,

    /// Output only. The number of rows affected by a DML statement. Present only
    /// for DML statements INSERT, UPDATE or DELETE.
    pub num_dml_affected_rows: std::option::Option<wkt::Int64Value>,

    /// Output only. The number of rows out of `total_rows` returned in this
    /// response.
    ///
    /// This feature is not yet available.
    pub page_row_count: i64,

    /// A token used for paging results. A non-empty token indicates that
    /// additional results are available. To see additional results,
    /// query the
    /// [`jobs.getQueryResults`](https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/getQueryResults)
    /// method. For more information, see [Paging through table
    /// data](https://cloud.google.com/bigquery/docs/paging-results).
    pub page_token: std::string::String,

    /// Output only. [Full-projection-only] String representation of identity of
    /// requesting party. Populated for both first- and third-party identities.
    /// Only present for APIs that support third-party identities.
    pub principal_subject: std::string::String,

    /// Auto-generated ID for the query.
    pub query_id: std::string::String,

    /// The schema of the results. Present only when the query completes
    /// successfully.
    pub schema: std::option::Option<google_cloud_bigquery_v2::model::TableSchema>,

    /// Output only. A URL that can be used to access the resource again.
    pub self_link: std::string::String,

    /// Output only. Information of the session if this job is part of one.
    pub session_info: std::option::Option<google_cloud_bigquery_v2::model::SessionInfo>,

    /// Output only. Start time of this query, in milliseconds since the epoch.
    /// This field will be present when the query job transitions from the PENDING
    /// state to either RUNNING or DONE.
    pub start_time: std::option::Option<i64>,

    /// Output only. The type of query statement, if valid.
    /// Possible values:
    ///
    /// * `SELECT`:
    ///   [`SELECT`](https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#select_list)
    ///   statement.
    /// * `ASSERT`:
    ///   [`ASSERT`](https://cloud.google.com/bigquery/docs/reference/standard-sql/debugging-statements#assert)
    ///   statement.
    /// * `INSERT`:
    ///   [`INSERT`](https://cloud.google.com/bigquery/docs/reference/standard-sql/dml-syntax#insert_statement)
    ///   statement.
    /// * `UPDATE`:
    ///   [`UPDATE`](https://cloud.google.com/bigquery/docs/reference/standard-sql/dml-syntax#update_statement)
    ///   statement.
    /// * `DELETE`:
    ///   [`DELETE`](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-manipulation-language)
    ///   statement.
    /// * `MERGE`:
    ///   [`MERGE`](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-manipulation-language)
    ///   statement.
    /// * `CREATE_TABLE`: [`CREATE
    ///   TABLE`](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#create_table_statement)
    ///   statement, without `AS SELECT`.
    /// * `CREATE_TABLE_AS_SELECT`: [`CREATE TABLE AS
    ///   SELECT`](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#create_table_statement)
    ///   statement.
    /// * `CREATE_VIEW`: [`CREATE
    ///   VIEW`](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#create_view_statement)
    ///   statement.
    /// * `CREATE_MODEL`: [`CREATE
    ///   MODEL`](https://cloud.google.com/bigquery-ml/docs/reference/standard-sql/bigqueryml-syntax-create#create_model_statement)
    ///   statement.
    /// * `CREATE_MATERIALIZED_VIEW`: [`CREATE MATERIALIZED
    ///   VIEW`](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#create_materialized_view_statement)
    ///   statement.
    /// * `CREATE_FUNCTION`: [`CREATE
    ///   FUNCTION`](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#create_function_statement)
    ///   statement.
    /// * `CREATE_TABLE_FUNCTION`: [`CREATE TABLE
    ///   FUNCTION`](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#create_table_function_statement)
    ///   statement.
    /// * `CREATE_PROCEDURE`: [`CREATE
    ///   PROCEDURE`](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#create_procedure)
    ///   statement.
    /// * `CREATE_ROW_ACCESS_POLICY`: [`CREATE ROW ACCESS
    ///   POLICY`](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#create_row_access_policy_statement)
    ///   statement.
    /// * `CREATE_SCHEMA`: [`CREATE
    ///   SCHEMA`](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#create_schema_statement)
    ///   statement.
    /// * `CREATE_SNAPSHOT_TABLE`: [`CREATE SNAPSHOT
    ///   TABLE`](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#create_snapshot_table_statement)
    ///   statement.
    /// * `CREATE_SEARCH_INDEX`: [`CREATE SEARCH
    ///   INDEX`](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#create_search_index_statement)
    ///   statement.
    /// * `DROP_TABLE`: [`DROP
    ///   TABLE`](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#drop_table_statement)
    ///   statement.
    /// * `DROP_EXTERNAL_TABLE`: [`DROP EXTERNAL
    ///   TABLE`](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#drop_external_table_statement)
    ///   statement.
    /// * `DROP_VIEW`: [`DROP
    ///   VIEW`](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#drop_view_statement)
    ///   statement.
    /// * `DROP_MODEL`: [`DROP
    ///   MODEL`](https://cloud.google.com/bigquery-ml/docs/reference/standard-sql/bigqueryml-syntax-drop-model)
    ///   statement.
    /// * `DROP_MATERIALIZED_VIEW`: [`DROP MATERIALIZED
    ///   VIEW`](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#drop_materialized_view_statement)
    ///   statement.
    /// * `DROP_FUNCTION` : [`DROP
    ///   FUNCTION`](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#drop_function_statement)
    ///   statement.
    /// * `DROP_TABLE_FUNCTION` : [`DROP TABLE
    ///   FUNCTION`](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#drop_table_function)
    ///   statement.
    /// * `DROP_PROCEDURE`: [`DROP
    ///   PROCEDURE`](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#drop_procedure_statement)
    ///   statement.
    /// * `DROP_SEARCH_INDEX`: [`DROP SEARCH
    ///   INDEX`](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#drop_search_index)
    ///   statement.
    /// * `DROP_SCHEMA`: [`DROP
    ///   SCHEMA`](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#drop_schema_statement)
    ///   statement.
    /// * `DROP_SNAPSHOT_TABLE`: [`DROP SNAPSHOT
    ///   TABLE`](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#drop_snapshot_table_statement)
    ///   statement.
    /// * `DROP_ROW_ACCESS_POLICY`: [`DROP [ALL] ROW ACCESS
    ///   POLICY|POLICIES`](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#drop_row_access_policy_statement)
    ///   statement.
    /// * `ALTER_TABLE`: [`ALTER
    ///   TABLE`](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#alter_table_set_options_statement)
    ///   statement.
    /// * `ALTER_VIEW`: [`ALTER
    ///   VIEW`](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#alter_view_set_options_statement)
    ///   statement.
    /// * `ALTER_MATERIALIZED_VIEW`: [`ALTER MATERIALIZED
    ///   VIEW`](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#alter_materialized_view_set_options_statement)
    ///   statement.
    /// * `ALTER_SCHEMA`: [`ALTER
    ///   SCHEMA`](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#alter_schema_set_options_statement)
    ///   statement.
    /// * `SCRIPT`:
    ///   [`SCRIPT`](https://cloud.google.com/bigquery/docs/reference/standard-sql/procedural-language).
    /// * `TRUNCATE_TABLE`: [`TRUNCATE
    ///   TABLE`](https://cloud.google.com/bigquery/docs/reference/standard-sql/dml-syntax#truncate_table_statement)
    ///   statement.
    /// * `CREATE_EXTERNAL_TABLE`: [`CREATE EXTERNAL
    ///   TABLE`](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#create_external_table_statement)
    ///   statement.
    /// * `EXPORT_DATA`: [`EXPORT
    ///   DATA`](https://cloud.google.com/bigquery/docs/reference/standard-sql/other-statements#export_data_statement)
    ///   statement.
    /// * `EXPORT_MODEL`: [`EXPORT
    ///   MODEL`](https://cloud.google.com/bigquery-ml/docs/reference/standard-sql/bigqueryml-syntax-export-model)
    ///   statement.
    /// * `LOAD_DATA`: [`LOAD
    ///   DATA`](https://cloud.google.com/bigquery/docs/reference/standard-sql/other-statements#load_data_statement)
    ///   statement.
    /// * `CALL`:
    ///   [`CALL`](https://cloud.google.com/bigquery/docs/reference/standard-sql/procedural-language#call)
    ///   statement.
    pub statement_type: std::string::String,

    /// Output only. Information about the job, including starting time and ending
    /// time of the job.
    pub statistics: std::option::Option<google_cloud_bigquery_v2::model::JobStatistics>,

    /// Output only. The status of this job. Examine this value when polling an
    /// asynchronous job to see if the job is complete.
    pub status: std::option::Option<google_cloud_bigquery_v2::model::JobStatus>,

    /// Output only. If the project is configured to use on-demand pricing,
    /// then this field contains the total bytes billed for the job.
    /// If the project is configured to use flat-rate pricing, then you are
    /// not billed for bytes and this field is informational only.
    pub total_bytes_billed: std::option::Option<i64>,

    /// The total number of bytes processed for this query. If this query was a dry
    /// run, this is the number of bytes that would be processed if the query were
    /// run.
    pub total_bytes_processed: std::option::Option<wkt::Int64Value>,

    /// The total number of rows in the complete query result set, which can be
    /// more than the number of rows in this single page of results.
    pub total_rows: std::option::Option<wkt::UInt64Value>,

    /// Output only. Number of slot ms the user is actually billed for.
    pub total_slot_ms: std::option::Option<i64>,

    /// Output only. Email address of the user who ran the job.
    pub user_email: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl QueryMetadata {
    /// Creates a new default instance.
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [cache_hit][crate::model_ext::QueryMetadata::cache_hit].
    pub fn set_cache_hit<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::BoolValue>,
    {
        self.cache_hit = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [cache_hit][crate::model_ext::QueryMetadata::cache_hit].
    pub fn set_or_clear_cache_hit<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::BoolValue>,
    {
        self.cache_hit = v.map(|x| x.into());
        self
    }

    /// Sets the value of [configuration][crate::model_ext::QueryMetadata::configuration].
    pub fn set_configuration<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<google_cloud_bigquery_v2::model::JobConfiguration>,
    {
        self.configuration = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [configuration][crate::model_ext::QueryMetadata::configuration].
    pub fn set_or_clear_configuration<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<google_cloud_bigquery_v2::model::JobConfiguration>,
    {
        self.configuration = v.map(|x| x.into());
        self
    }

    /// Sets the value of [creation_time][crate::model_ext::QueryMetadata::creation_time].
    pub fn set_creation_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<i64>,
    {
        self.creation_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [creation_time][crate::model_ext::QueryMetadata::creation_time].
    pub fn set_or_clear_creation_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<i64>,
    {
        self.creation_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [dml_stats][crate::model_ext::QueryMetadata::dml_stats].
    pub fn set_dml_stats<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<google_cloud_bigquery_v2::model::DmlStats>,
    {
        self.dml_stats = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [dml_stats][crate::model_ext::QueryMetadata::dml_stats].
    pub fn set_or_clear_dml_stats<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<google_cloud_bigquery_v2::model::DmlStats>,
    {
        self.dml_stats = v.map(|x| x.into());
        self
    }

    /// Sets the value of [end_time][crate::model_ext::QueryMetadata::end_time].
    pub fn set_end_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<i64>,
    {
        self.end_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [end_time][crate::model_ext::QueryMetadata::end_time].
    pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<i64>,
    {
        self.end_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [errors][crate::model_ext::QueryMetadata::errors].
    pub fn set_errors<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<google_cloud_bigquery_v2::model::ErrorProto>,
    {
        use std::iter::Iterator;
        self.errors = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [etag][crate::model_ext::QueryMetadata::etag].
    pub fn set_etag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.etag = v.into();
        self
    }

    /// Sets the value of [id][crate::model_ext::QueryMetadata::id].
    pub fn set_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.id = v.into();
        self
    }

    /// Sets the value of [job_complete][crate::model_ext::QueryMetadata::job_complete].
    pub fn set_job_complete<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::BoolValue>,
    {
        self.job_complete = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [job_complete][crate::model_ext::QueryMetadata::job_complete].
    pub fn set_or_clear_job_complete<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::BoolValue>,
    {
        self.job_complete = v.map(|x| x.into());
        self
    }

    /// Sets the value of [job_creation_reason][crate::model_ext::QueryMetadata::job_creation_reason].
    pub fn set_job_creation_reason<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<google_cloud_bigquery_v2::model::JobCreationReason>,
    {
        self.job_creation_reason = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [job_creation_reason][crate::model_ext::QueryMetadata::job_creation_reason].
    pub fn set_or_clear_job_creation_reason<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<google_cloud_bigquery_v2::model::JobCreationReason>,
    {
        self.job_creation_reason = v.map(|x| x.into());
        self
    }

    /// Sets the value of [job_reference][crate::model_ext::QueryMetadata::job_reference].
    pub fn set_job_reference<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<google_cloud_bigquery_v2::model::JobReference>,
    {
        self.job_reference = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [job_reference][crate::model_ext::QueryMetadata::job_reference].
    pub fn set_or_clear_job_reference<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<google_cloud_bigquery_v2::model::JobReference>,
    {
        self.job_reference = v.map(|x| x.into());
        self
    }

    /// Sets the value of [kind][crate::model_ext::QueryMetadata::kind].
    pub fn set_kind<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.kind = v.into();
        self
    }

    /// Sets the value of [location][crate::model_ext::QueryMetadata::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 [num_dml_affected_rows][crate::model_ext::QueryMetadata::num_dml_affected_rows].
    pub fn set_num_dml_affected_rows<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Int64Value>,
    {
        self.num_dml_affected_rows = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [num_dml_affected_rows][crate::model_ext::QueryMetadata::num_dml_affected_rows].
    pub fn set_or_clear_num_dml_affected_rows<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Int64Value>,
    {
        self.num_dml_affected_rows = v.map(|x| x.into());
        self
    }

    /// Sets the value of [page_row_count][crate::model_ext::QueryMetadata::page_row_count].
    pub fn set_page_row_count<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
        self.page_row_count = v.into();
        self
    }

    /// Sets the value of [page_token][crate::model_ext::QueryMetadata::page_token].
    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.page_token = v.into();
        self
    }

    /// Sets the value of [principal_subject][crate::model_ext::QueryMetadata::principal_subject].
    pub fn set_principal_subject<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.principal_subject = v.into();
        self
    }

    /// Sets the value of [query_id][crate::model_ext::QueryMetadata::query_id].
    pub fn set_query_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.query_id = v.into();
        self
    }

    /// Sets the value of [schema][crate::model_ext::QueryMetadata::schema].
    pub fn set_schema<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<google_cloud_bigquery_v2::model::TableSchema>,
    {
        self.schema = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [schema][crate::model_ext::QueryMetadata::schema].
    pub fn set_or_clear_schema<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<google_cloud_bigquery_v2::model::TableSchema>,
    {
        self.schema = v.map(|x| x.into());
        self
    }

    /// Sets the value of [self_link][crate::model_ext::QueryMetadata::self_link].
    pub fn set_self_link<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.self_link = v.into();
        self
    }

    /// Sets the value of [session_info][crate::model_ext::QueryMetadata::session_info].
    pub fn set_session_info<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<google_cloud_bigquery_v2::model::SessionInfo>,
    {
        self.session_info = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [session_info][crate::model_ext::QueryMetadata::session_info].
    pub fn set_or_clear_session_info<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<google_cloud_bigquery_v2::model::SessionInfo>,
    {
        self.session_info = v.map(|x| x.into());
        self
    }

    /// Sets the value of [start_time][crate::model_ext::QueryMetadata::start_time].
    pub fn set_start_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<i64>,
    {
        self.start_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [start_time][crate::model_ext::QueryMetadata::start_time].
    pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<i64>,
    {
        self.start_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [statement_type][crate::model_ext::QueryMetadata::statement_type].
    pub fn set_statement_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.statement_type = v.into();
        self
    }

    /// Sets the value of [statistics][crate::model_ext::QueryMetadata::statistics].
    pub fn set_statistics<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<google_cloud_bigquery_v2::model::JobStatistics>,
    {
        self.statistics = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [statistics][crate::model_ext::QueryMetadata::statistics].
    pub fn set_or_clear_statistics<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<google_cloud_bigquery_v2::model::JobStatistics>,
    {
        self.statistics = v.map(|x| x.into());
        self
    }

    /// Sets the value of [status][crate::model_ext::QueryMetadata::status].
    pub fn set_status<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<google_cloud_bigquery_v2::model::JobStatus>,
    {
        self.status = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [status][crate::model_ext::QueryMetadata::status].
    pub fn set_or_clear_status<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<google_cloud_bigquery_v2::model::JobStatus>,
    {
        self.status = v.map(|x| x.into());
        self
    }

    /// Sets the value of [total_bytes_billed][crate::model_ext::QueryMetadata::total_bytes_billed].
    pub fn set_total_bytes_billed<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<i64>,
    {
        self.total_bytes_billed = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [total_bytes_billed][crate::model_ext::QueryMetadata::total_bytes_billed].
    pub fn set_or_clear_total_bytes_billed<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<i64>,
    {
        self.total_bytes_billed = v.map(|x| x.into());
        self
    }

    /// Sets the value of [total_bytes_processed][crate::model_ext::QueryMetadata::total_bytes_processed].
    pub fn set_total_bytes_processed<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Int64Value>,
    {
        self.total_bytes_processed = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [total_bytes_processed][crate::model_ext::QueryMetadata::total_bytes_processed].
    pub fn set_or_clear_total_bytes_processed<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Int64Value>,
    {
        self.total_bytes_processed = v.map(|x| x.into());
        self
    }

    /// Sets the value of [total_rows][crate::model_ext::QueryMetadata::total_rows].
    pub fn set_total_rows<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::UInt64Value>,
    {
        self.total_rows = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [total_rows][crate::model_ext::QueryMetadata::total_rows].
    pub fn set_or_clear_total_rows<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::UInt64Value>,
    {
        self.total_rows = v.map(|x| x.into());
        self
    }

    /// Sets the value of [total_slot_ms][crate::model_ext::QueryMetadata::total_slot_ms].
    pub fn set_total_slot_ms<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<i64>,
    {
        self.total_slot_ms = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [total_slot_ms][crate::model_ext::QueryMetadata::total_slot_ms].
    pub fn set_or_clear_total_slot_ms<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<i64>,
    {
        self.total_slot_ms = v.map(|x| x.into());
        self
    }

    /// Sets the value of [user_email][crate::model_ext::QueryMetadata::user_email].
    pub fn set_user_email<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.user_email = v.into();
        self
    }
}

mod debug {

    impl std::fmt::Debug for super::QueryMetadata {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            let mut debug_struct = f.debug_struct("QueryMetadata");
            debug_struct.field("cache_hit", &self.cache_hit);
            debug_struct.field("configuration", &self.configuration);
            debug_struct.field("creation_time", &self.creation_time);
            debug_struct.field("dml_stats", &self.dml_stats);
            debug_struct.field("end_time", &self.end_time);
            debug_struct.field("errors", &self.errors);
            debug_struct.field("etag", &self.etag);
            debug_struct.field("id", &self.id);
            debug_struct.field("job_complete", &self.job_complete);
            debug_struct.field("job_creation_reason", &self.job_creation_reason);
            debug_struct.field("job_reference", &self.job_reference);
            debug_struct.field("kind", &self.kind);
            debug_struct.field("location", &self.location);
            debug_struct.field("num_dml_affected_rows", &self.num_dml_affected_rows);
            debug_struct.field("page_row_count", &self.page_row_count);
            debug_struct.field("page_token", &self.page_token);
            debug_struct.field("principal_subject", &self.principal_subject);
            debug_struct.field("query_id", &self.query_id);
            debug_struct.field("schema", &self.schema);
            debug_struct.field("self_link", &self.self_link);
            debug_struct.field("session_info", &self.session_info);
            debug_struct.field("start_time", &self.start_time);
            debug_struct.field("statement_type", &self.statement_type);
            debug_struct.field("statistics", &self.statistics);
            debug_struct.field("status", &self.status);
            debug_struct.field("total_bytes_billed", &self.total_bytes_billed);
            debug_struct.field("total_bytes_processed", &self.total_bytes_processed);
            debug_struct.field("total_rows", &self.total_rows);
            debug_struct.field("total_slot_ms", &self.total_slot_ms);
            debug_struct.field("user_email", &self.user_email);
            if !self._unknown_fields.is_empty() {
                debug_struct.field("_unknown_fields", &self._unknown_fields);
            }
            debug_struct.finish()
        }
    }
}

impl std::convert::From<google_cloud_bigquery_v2::model::Job> for QueryMetadata {
    fn from(resp: google_cloud_bigquery_v2::model::Job) -> Self {
        Self {
            configuration: resp.configuration,
            etag: resp.etag,
            id: resp.id,
            job_creation_reason: resp.job_creation_reason,
            job_reference: resp.job_reference,
            kind: resp.kind,
            principal_subject: resp.principal_subject,
            self_link: resp.self_link,
            statistics: resp.statistics,
            status: resp.status,
            user_email: resp.user_email,
            ..Default::default()
        }
    }
}

impl std::convert::From<google_cloud_bigquery_v2::model::QueryResponse> for QueryMetadata {
    fn from(resp: google_cloud_bigquery_v2::model::QueryResponse) -> Self {
        Self {
            cache_hit: resp.cache_hit,
            creation_time: resp.creation_time,
            dml_stats: resp.dml_stats,
            end_time: resp.end_time,
            errors: resp.errors,
            job_complete: resp.job_complete,
            job_creation_reason: resp.job_creation_reason,
            job_reference: resp.job_reference,
            kind: resp.kind,
            location: resp.location,
            num_dml_affected_rows: resp.num_dml_affected_rows,
            page_row_count: resp.page_row_count,
            page_token: resp.page_token,
            query_id: resp.query_id,
            schema: resp.schema,
            session_info: resp.session_info,
            start_time: resp.start_time,
            statement_type: resp.statement_type,
            total_bytes_billed: resp.total_bytes_billed,
            total_bytes_processed: resp.total_bytes_processed,
            total_rows: resp.total_rows,
            total_slot_ms: resp.total_slot_ms,
            ..Default::default()
        }
    }
}

impl std::convert::From<QueryMetadata> for crate::generated::CompleteQueryMetadata {
    fn from(md: QueryMetadata) -> Self {
        crate::generated::CompleteQueryMetadata {
            cache_hit: md.cache_hit,
            creation_time: md.creation_time,
            dml_stats: md.dml_stats,
            end_time: md.end_time,
            errors: md.errors,
            job_complete: md.job_complete,
            job_creation_reason: md.job_creation_reason,
            job_reference: md.job_reference,
            kind: md.kind,
            location: md.location,
            num_dml_affected_rows: md.num_dml_affected_rows,
            page_row_count: md.page_row_count,
            page_token: md.page_token,
            query_id: md.query_id,
            schema: md.schema,
            session_info: md.session_info,
            start_time: md.start_time,
            statement_type: md.statement_type,
            total_bytes_billed: md.total_bytes_billed,
            total_bytes_processed: md.total_bytes_processed,
            total_rows: md.total_rows,
            total_slot_ms: md.total_slot_ms,
            ..Default::default()
        }
    }
}