google-cloud-bigquery 1.35.0 → 1.38.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -744,7 +744,7 @@ module Google
744
744
  # See {Schema#string}.
745
745
  #
746
746
  # @param [String] name The field name. The name must contain only
747
- # letters (a-z, A-Z), numbers (0-9), or underscores (_), and must
747
+ # letters (`[A-Za-z]`), numbers (`[0-9]`), or underscores (`_`), and must
748
748
  # start with a letter or underscore. The maximum length is 128
749
749
  # characters.
750
750
  # @param [String] description A description of the field.
@@ -778,7 +778,7 @@ module Google
778
778
  # See {Schema#integer}.
779
779
  #
780
780
  # @param [String] name The field name. The name must contain only
781
- # letters (a-z, A-Z), numbers (0-9), or underscores (_), and must
781
+ # letters (`[A-Za-z]`), numbers (`[0-9]`), or underscores (`_`), and must
782
782
  # start with a letter or underscore. The maximum length is 128
783
783
  # characters.
784
784
  # @param [String] description A description of the field.
@@ -810,7 +810,7 @@ module Google
810
810
  # See {Schema#float}.
811
811
  #
812
812
  # @param [String] name The field name. The name must contain only
813
- # letters (a-z, A-Z), numbers (0-9), or underscores (_), and must
813
+ # letters (`[A-Za-z]`), numbers (`[0-9]`), or underscores (`_`), and must
814
814
  # start with a letter or underscore. The maximum length is 128
815
815
  # characters.
816
816
  # @param [String] description A description of the field.
@@ -853,7 +853,7 @@ module Google
853
853
  # See {Schema#numeric}
854
854
  #
855
855
  # @param [String] name The field name. The name must contain only
856
- # letters (a-z, A-Z), numbers (0-9), or underscores (_), and must
856
+ # letters (`[A-Za-z]`), numbers (`[0-9]`), or underscores (`_`), and must
857
857
  # start with a letter or underscore. The maximum length is 128
858
858
  # characters.
859
859
  # @param [String] description A description of the field.
@@ -911,7 +911,7 @@ module Google
911
911
  # See {Schema#bignumeric}
912
912
  #
913
913
  # @param [String] name The field name. The name must contain only
914
- # letters (a-z, A-Z), numbers (0-9), or underscores (_), and must
914
+ # letters (`[A-Za-z]`), numbers (`[0-9]`), or underscores (`_`), and must
915
915
  # start with a letter or underscore. The maximum length is 128
916
916
  # characters.
917
917
  # @param [String] description A description of the field.
@@ -958,7 +958,7 @@ module Google
958
958
  # See {Schema#boolean}.
959
959
  #
960
960
  # @param [String] name The field name. The name must contain only
961
- # letters (a-z, A-Z), numbers (0-9), or underscores (_), and must
961
+ # letters (`[A-Za-z]`), numbers (`[0-9]`), or underscores (`_`), and must
962
962
  # start with a letter or underscore. The maximum length is 128
963
963
  # characters.
964
964
  # @param [String] description A description of the field.
@@ -990,7 +990,7 @@ module Google
990
990
  # See {Schema#bytes}.
991
991
  #
992
992
  # @param [String] name The field name. The name must contain only
993
- # letters (a-z, A-Z), numbers (0-9), or underscores (_), and must
993
+ # letters (`[A-Za-z]`), numbers (`[0-9]`), or underscores (`_`), and must
994
994
  # start with a letter or underscore. The maximum length is 128
995
995
  # characters.
996
996
  # @param [String] description A description of the field.
@@ -1024,7 +1024,7 @@ module Google
1024
1024
  # See {Schema#timestamp}.
1025
1025
  #
1026
1026
  # @param [String] name The field name. The name must contain only
1027
- # letters (a-z, A-Z), numbers (0-9), or underscores (_), and must
1027
+ # letters (`[A-Za-z]`), numbers (`[0-9]`), or underscores (`_`), and must
1028
1028
  # start with a letter or underscore. The maximum length is 128
1029
1029
  # characters.
1030
1030
  # @param [String] description A description of the field.
@@ -1056,7 +1056,7 @@ module Google
1056
1056
  # See {Schema#time}.
1057
1057
  #
1058
1058
  # @param [String] name The field name. The name must contain only
1059
- # letters (a-z, A-Z), numbers (0-9), or underscores (_), and must
1059
+ # letters (`[A-Za-z]`), numbers (`[0-9]`), or underscores (`_`), and must
1060
1060
  # start with a letter or underscore. The maximum length is 128
1061
1061
  # characters.
1062
1062
  # @param [String] description A description of the field.
@@ -1088,7 +1088,7 @@ module Google
1088
1088
  # See {Schema#datetime}.
1089
1089
  #
1090
1090
  # @param [String] name The field name. The name must contain only
1091
- # letters (a-z, A-Z), numbers (0-9), or underscores (_), and must
1091
+ # letters (`[A-Za-z]`), numbers (`[0-9]`), or underscores (`_`), and must
1092
1092
  # start with a letter or underscore. The maximum length is 128
1093
1093
  # characters.
1094
1094
  # @param [String] description A description of the field.
@@ -1120,7 +1120,7 @@ module Google
1120
1120
  # See {Schema#date}.
1121
1121
  #
1122
1122
  # @param [String] name The field name. The name must contain only
1123
- # letters (a-z, A-Z), numbers (0-9), or underscores (_), and must
1123
+ # letters (`[A-Za-z]`), numbers (`[0-9]`), or underscores (`_`), and must
1124
1124
  # start with a letter or underscore. The maximum length is 128
1125
1125
  # characters.
1126
1126
  # @param [String] description A description of the field.
@@ -1154,7 +1154,7 @@ module Google
1154
1154
  # @see https://cloud.google.com/bigquery/docs/gis-data Working with BigQuery GIS data
1155
1155
  #
1156
1156
  # @param [String] name The field name. The name must contain only
1157
- # letters (a-z, A-Z), numbers (0-9), or underscores (_), and must
1157
+ # letters (`[A-Za-z]`), numbers (`[0-9]`), or underscores (`_`), and must
1158
1158
  # start with a letter or underscore. The maximum length is 128
1159
1159
  # characters.
1160
1160
  # @param [String] description A description of the field.
@@ -1192,7 +1192,7 @@ module Google
1192
1192
  # See {Schema#record}.
1193
1193
  #
1194
1194
  # @param [String] name The field name. The name must contain only
1195
- # letters (a-z, A-Z), numbers (0-9), or underscores (_), and must
1195
+ # letters (`[A-Za-z]`), numbers (`[0-9]`), or underscores (`_`), and must
1196
1196
  # start with a letter or underscore. The maximum length is 128
1197
1197
  # characters.
1198
1198
  # @param [String] description A description of the field.
@@ -87,8 +87,8 @@ module Google
87
87
  ##
88
88
  # A unique ID for this model.
89
89
  #
90
- # @return [String] The ID must contain only letters (a-z, A-Z), numbers
91
- # (0-9), or underscores (_). The maximum length is 1,024 characters.
90
+ # @return [String] The ID must contain only letters (`[A-Za-z]`), numbers
91
+ # (`[0-9]`), or underscores (`_`). The maximum length is 1,024 characters.
92
92
  #
93
93
  # @!group Attributes
94
94
  #
@@ -100,8 +100,8 @@ module Google
100
100
  ##
101
101
  # The ID of the `Dataset` containing this model.
102
102
  #
103
- # @return [String] The ID must contain only letters (a-z, A-Z), numbers
104
- # (0-9), or underscores (_). The maximum length is 1,024 characters.
103
+ # @return [String] The ID must contain only letters (`[A-Za-z]`), numbers
104
+ # (`[0-9]`), or underscores (`_`). The maximum length is 1,024 characters.
105
105
  #
106
106
  # @!group Attributes
107
107
  #
@@ -515,8 +515,8 @@ module Google
515
515
  # * `ml_tf_saved_model` - TensorFlow SavedModel
516
516
  # * `ml_xgboost_booster` - XGBoost Booster
517
517
  # @param [String] job_id A user-defined ID for the extract job. The ID
518
- # must contain only letters (a-z, A-Z), numbers (0-9), underscores
519
- # (_), or dashes (-). The maximum length is 1,024 characters. If
518
+ # must contain only letters (`[A-Za-z]`), numbers (`[0-9]`), underscores
519
+ # (`_`), or dashes (`-`). The maximum length is 1,024 characters. If
520
520
  # `job_id` is provided, then `prefix` will not be used.
521
521
  #
522
522
  # See [Generating a job
@@ -525,8 +525,8 @@ module Google
525
525
  # prepended to a generated value to produce a unique job ID. For
526
526
  # example, the prefix `daily_import_job_` can be given to generate a
527
527
  # job ID such as `daily_import_job_12vEDtMQ0mbp1Mo5Z7mzAFQJZazh`. The
528
- # prefix must contain only letters (a-z, A-Z), numbers (0-9),
529
- # underscores (_), or dashes (-). The maximum length of the entire ID
528
+ # prefix must contain only letters (`[A-Za-z]`), numbers (`[0-9]`),
529
+ # underscores (`_`), or dashes (`-`). The maximum length of the entire ID
530
530
  # is 1,024 characters. If `job_id` is provided, then `prefix` will not
531
531
  # be used.
532
532
  # @param [Hash] labels A hash of user-provided labels associated with
@@ -139,8 +139,8 @@ module Google
139
139
  # * `empty` - An error will be returned if the destination table
140
140
  # already contains data.
141
141
  # @param [String] job_id A user-defined ID for the copy job. The ID
142
- # must contain only letters (a-z, A-Z), numbers (0-9), underscores
143
- # (_), or dashes (-). The maximum length is 1,024 characters. If
142
+ # must contain only letters (`[A-Za-z]`), numbers (`[0-9]`), underscores
143
+ # (`_`), or dashes (`-`). The maximum length is 1,024 characters. If
144
144
  # `job_id` is provided, then `prefix` will not be used.
145
145
  #
146
146
  # See [Generating a job
@@ -149,8 +149,8 @@ module Google
149
149
  # prepended to a generated value to produce a unique job ID. For
150
150
  # example, the prefix `daily_import_job_` can be given to generate a
151
151
  # job ID such as `daily_import_job_12vEDtMQ0mbp1Mo5Z7mzAFQJZazh`. The
152
- # prefix must contain only letters (a-z, A-Z), numbers (0-9),
153
- # underscores (_), or dashes (-). The maximum length of the entire ID
152
+ # prefix must contain only letters (`[A-Za-z]`), numbers (`[0-9]`),
153
+ # underscores (`_`), or dashes (`-`). The maximum length of the entire ID
154
154
  # is 1,024 characters. If `job_id` is provided, then `prefix` will not
155
155
  # be used.
156
156
  # @param [Hash] labels A hash of user-provided labels associated with
@@ -402,13 +402,19 @@ module Google
402
402
  # Flattens all nested and repeated fields in the query results. The
403
403
  # default value is `true`. `large_results` parameter must be `true` if
404
404
  # this is set to `false`.
405
+ # @param [Integer] maximum_billing_tier Limits the billing tier for this
406
+ # job. Queries that have resource usage beyond this tier will fail
407
+ # (without incurring a charge). WARNING: The billed byte amount can be
408
+ # multiplied by an amount up to this number! Most users should not need
409
+ # to alter this setting, and we recommend that you avoid introducing new
410
+ # uses of it. Deprecated.
405
411
  # @param [Integer] maximum_bytes_billed Limits the bytes billed for this
406
412
  # job. Queries that will have bytes billed beyond this limit will fail
407
413
  # (without incurring a charge). Optional. If unspecified, this will be
408
414
  # set to your project default.
409
415
  # @param [String] job_id A user-defined ID for the query job. The ID
410
- # must contain only letters (a-z, A-Z), numbers (0-9), underscores
411
- # (_), or dashes (-). The maximum length is 1,024 characters. If
416
+ # must contain only letters (`[A-Za-z]`), numbers (`[0-9]`), underscores
417
+ # (`_`), or dashes (`-`). The maximum length is 1,024 characters. If
412
418
  # `job_id` is provided, then `prefix` will not be used.
413
419
  #
414
420
  # See [Generating a job
@@ -417,8 +423,8 @@ module Google
417
423
  # prepended to a generated value to produce a unique job ID. For
418
424
  # example, the prefix `daily_import_job_` can be given to generate a
419
425
  # job ID such as `daily_import_job_12vEDtMQ0mbp1Mo5Z7mzAFQJZazh`. The
420
- # prefix must contain only letters (a-z, A-Z), numbers (0-9),
421
- # underscores (_), or dashes (-). The maximum length of the entire ID
426
+ # prefix must contain only letters (`[A-Za-z]`), numbers (`[0-9]`),
427
+ # underscores (`_`), or dashes (`-`). The maximum length of the entire ID
422
428
  # is 1,024 characters. If `job_id` is provided, then `prefix` will not
423
429
  # be used.
424
430
  #
@@ -455,8 +461,13 @@ module Google
455
461
  # For additional information on migrating, see: [Migrating to
456
462
  # standard SQL - Differences in user-defined JavaScript
457
463
  # functions](https://cloud.google.com/bigquery/docs/reference/standard-sql/migrating-from-legacy-sql#differences_in_user-defined_javascript_functions)
458
- # @param [Integer] maximum_billing_tier Deprecated: Change the billing
459
- # tier to allow high-compute queries.
464
+ # @param [Boolean] create_session If true, creates a new session, where the
465
+ # session ID will be a server generated random id. If false, runs query
466
+ # with an existing session ID when one is provided in the `session_id`
467
+ # param, otherwise runs query in non-session mode. See {Job#session_id}.
468
+ # The default value is false.
469
+ # @param [String] session_id The ID of an existing session. See also the
470
+ # `create_session` param and {Job#session_id}.
460
471
  # @yield [job] a job configuration object
461
472
  # @yieldparam [Google::Cloud::Bigquery::QueryJob::Updater] job a job
462
473
  # configuration object for setting query options.
@@ -468,8 +479,7 @@ module Google
468
479
  #
469
480
  # bigquery = Google::Cloud::Bigquery.new
470
481
  #
471
- # job = bigquery.query_job "SELECT name FROM " \
472
- # "`my_project.my_dataset.my_table`"
482
+ # job = bigquery.query_job "SELECT name FROM `my_project.my_dataset.my_table`"
473
483
  #
474
484
  # job.wait_until_done!
475
485
  # if !job.failed?
@@ -483,8 +493,7 @@ module Google
483
493
  #
484
494
  # bigquery = Google::Cloud::Bigquery.new
485
495
  #
486
- # job = bigquery.query_job "SELECT name FROM " \
487
- # " [my_project:my_dataset.my_table]",
496
+ # job = bigquery.query_job "SELECT name FROM [my_project:my_dataset.my_table]",
488
497
  # legacy_sql: true
489
498
  #
490
499
  # job.wait_until_done!
@@ -499,9 +508,7 @@ module Google
499
508
  #
500
509
  # bigquery = Google::Cloud::Bigquery.new
501
510
  #
502
- # job = bigquery.query_job "SELECT name FROM " \
503
- # "`my_dataset.my_table` " \
504
- # "WHERE id = ?",
511
+ # job = bigquery.query_job "SELECT name FROM `my_dataset.my_table` WHERE id = ?",
505
512
  # params: [1]
506
513
  #
507
514
  # job.wait_until_done!
@@ -516,9 +523,7 @@ module Google
516
523
  #
517
524
  # bigquery = Google::Cloud::Bigquery.new
518
525
  #
519
- # job = bigquery.query_job "SELECT name FROM " \
520
- # "`my_dataset.my_table` " \
521
- # "WHERE id = @id",
526
+ # job = bigquery.query_job "SELECT name FROM `my_dataset.my_table` WHERE id = @id",
522
527
  # params: { id: 1 }
523
528
  #
524
529
  # job.wait_until_done!
@@ -533,9 +538,7 @@ module Google
533
538
  #
534
539
  # bigquery = Google::Cloud::Bigquery.new
535
540
  #
536
- # job = bigquery.query_job "SELECT name FROM " \
537
- # "`my_dataset.my_table` " \
538
- # "WHERE id IN UNNEST(@ids)",
541
+ # job = bigquery.query_job "SELECT name FROM `my_dataset.my_table` WHERE id IN UNNEST(@ids)",
539
542
  # params: { ids: [] },
540
543
  # types: { ids: [:INT64] }
541
544
  #
@@ -551,9 +554,7 @@ module Google
551
554
  #
552
555
  # bigquery = Google::Cloud::Bigquery.new
553
556
  #
554
- # job = bigquery.query_job "CREATE TABLE " \
555
- # "`my_dataset.my_table` " \
556
- # "(x INT64)"
557
+ # job = bigquery.query_job "CREATE TABLE`my_dataset.my_table` (x INT64)"
557
558
  #
558
559
  # job.wait_until_done!
559
560
  # if !job.failed?
@@ -565,10 +566,7 @@ module Google
565
566
  #
566
567
  # bigquery = Google::Cloud::Bigquery.new
567
568
  #
568
- # job = bigquery.query_job "UPDATE " \
569
- # "`my_dataset.my_table` " \
570
- # "SET x = x + 1 " \
571
- # "WHERE x IS NOT NULL"
569
+ # job = bigquery.query_job "UPDATE `my_dataset.my_table` SET x = x + 1 WHERE x IS NOT NULL"
572
570
  #
573
571
  # job.wait_until_done!
574
572
  # if !job.failed?
@@ -599,17 +597,56 @@ module Google
599
597
  # end
600
598
  # end
601
599
  #
602
- def query_job query, params: nil, types: nil, external: nil, priority: "INTERACTIVE", cache: true, table: nil,
603
- create: nil, write: nil, dryrun: nil, dataset: nil, project: nil, standard_sql: nil,
604
- legacy_sql: nil, large_results: nil, flatten: nil, maximum_billing_tier: nil,
605
- maximum_bytes_billed: nil, job_id: nil, prefix: nil, labels: nil, udfs: nil
600
+ def query_job query,
601
+ params: nil,
602
+ types: nil,
603
+ external: nil,
604
+ priority: "INTERACTIVE",
605
+ cache: true,
606
+ table: nil,
607
+ create: nil,
608
+ write: nil,
609
+ dryrun: nil,
610
+ dataset: nil,
611
+ project: nil,
612
+ standard_sql: nil,
613
+ legacy_sql: nil,
614
+ large_results: nil,
615
+ flatten: nil,
616
+ maximum_billing_tier: nil,
617
+ maximum_bytes_billed: nil,
618
+ job_id: nil,
619
+ prefix: nil,
620
+ labels: nil,
621
+ udfs: nil,
622
+ create_session: nil,
623
+ session_id: nil
606
624
  ensure_service!
607
- options = { params: params, types: types, external: external, priority: priority, cache: cache, table: table,
608
- create: create, write: write, dryrun: dryrun, dataset: dataset,
609
- project: (project || self.project), standard_sql: standard_sql, legacy_sql: legacy_sql,
610
- large_results: large_results, flatten: flatten, maximum_billing_tier: maximum_billing_tier,
611
- maximum_bytes_billed: maximum_bytes_billed, job_id: job_id, prefix: prefix, labels: labels,
612
- udfs: udfs }
625
+ options = {
626
+ params: params,
627
+ types: types,
628
+ external: external,
629
+ priority: priority,
630
+ cache: cache,
631
+ table: table,
632
+ create: create,
633
+ write: write,
634
+ dryrun: dryrun,
635
+ dataset: dataset,
636
+ project: (project || self.project),
637
+ standard_sql: standard_sql,
638
+ legacy_sql: legacy_sql,
639
+ large_results: large_results,
640
+ flatten: flatten,
641
+ maximum_billing_tier: maximum_billing_tier,
642
+ maximum_bytes_billed: maximum_bytes_billed,
643
+ job_id: job_id,
644
+ prefix: prefix,
645
+ labels: labels,
646
+ udfs: udfs,
647
+ create_session: create_session,
648
+ session_id: session_id
649
+ }
613
650
 
614
651
  updater = QueryJob::Updater.from_options service, query, options
615
652
 
@@ -730,6 +767,8 @@ module Google
730
767
  # When set to false, the values of `large_results` and `flatten` are
731
768
  # ignored; the query will be run as if `large_results` is true and
732
769
  # `flatten` is false. Optional. The default value is false.
770
+ # @param [String] session_id The ID of an existing session. See the
771
+ # `create_session` param in {#query_job} and {Job#session_id}.
733
772
  # @yield [job] a job configuration object
734
773
  # @yieldparam [Google::Cloud::Bigquery::QueryJob::Updater] job a job
735
774
  # configuration object for setting additional options for the query.
@@ -782,9 +821,7 @@ module Google
782
821
  #
783
822
  # bigquery = Google::Cloud::Bigquery.new
784
823
  #
785
- # data = bigquery.query "SELECT name " \
786
- # "FROM `my_dataset.my_table` " \
787
- # "WHERE id = ?",
824
+ # data = bigquery.query "SELECT name FROM `my_dataset.my_table` WHERE id = ?",
788
825
  # params: [1]
789
826
  #
790
827
  # # Iterate over the first page of results
@@ -799,9 +836,7 @@ module Google
799
836
  #
800
837
  # bigquery = Google::Cloud::Bigquery.new
801
838
  #
802
- # data = bigquery.query "SELECT name " \
803
- # "FROM `my_dataset.my_table` " \
804
- # "WHERE id = @id",
839
+ # data = bigquery.query "SELECT name FROM `my_dataset.my_table` WHERE id = @id",
805
840
  # params: { id: 1 }
806
841
  #
807
842
  # # Iterate over the first page of results
@@ -816,9 +851,7 @@ module Google
816
851
  #
817
852
  # bigquery = Google::Cloud::Bigquery.new
818
853
  #
819
- # data = bigquery.query "SELECT name FROM " \
820
- # "`my_dataset.my_table` " \
821
- # "WHERE id IN UNNEST(@ids)",
854
+ # data = bigquery.query "SELECT name FROM `my_dataset.my_table` WHERE id IN UNNEST(@ids)",
822
855
  # params: { ids: [] },
823
856
  # types: { ids: [:INT64] }
824
857
  #
@@ -843,9 +876,7 @@ module Google
843
876
  #
844
877
  # bigquery = Google::Cloud::Bigquery.new
845
878
  #
846
- # data = bigquery.query "UPDATE `my_dataset.my_table` " \
847
- # "SET x = x + 1 " \
848
- # "WHERE x IS NOT NULL"
879
+ # data = bigquery.query "UPDATE `my_dataset.my_table` SET x = x + 1 WHERE x IS NOT NULL"
849
880
  #
850
881
  # puts data.num_dml_affected_rows
851
882
  #
@@ -873,10 +904,29 @@ module Google
873
904
  # # Retrieve the next page of results
874
905
  # data = data.next if data.next?
875
906
  #
876
- def query query, params: nil, types: nil, external: nil, max: nil, cache: true, dataset: nil, project: nil,
877
- standard_sql: nil, legacy_sql: nil, &block
878
- job = query_job query, params: params, types: types, external: external, cache: cache, dataset: dataset,
879
- project: project, standard_sql: standard_sql, legacy_sql: legacy_sql, &block
907
+ def query query,
908
+ params: nil,
909
+ types: nil,
910
+ external: nil,
911
+ max: nil,
912
+ cache: true,
913
+ dataset: nil,
914
+ project: nil,
915
+ standard_sql: nil,
916
+ legacy_sql: nil,
917
+ session_id: nil,
918
+ &block
919
+ job = query_job query,
920
+ params: params,
921
+ types: types,
922
+ external: external,
923
+ cache: cache,
924
+ dataset: dataset,
925
+ project: project,
926
+ standard_sql: standard_sql,
927
+ legacy_sql: legacy_sql,
928
+ session_id: session_id,
929
+ &block
880
930
  job.wait_until_done!
881
931
 
882
932
  if job.failed?
@@ -986,8 +1036,8 @@ module Google
986
1036
  # Creates a new dataset.
987
1037
  #
988
1038
  # @param [String] dataset_id A unique ID for this dataset, without the
989
- # project name. The ID must contain only letters (a-z, A-Z), numbers
990
- # (0-9), or underscores (_). The maximum length is 1,024 characters.
1039
+ # project name. The ID must contain only letters (`[A-Za-z]`), numbers
1040
+ # (`[0-9]`), or underscores (`_`). The maximum length is 1,024 characters.
991
1041
  # @param [String] name A descriptive name for the dataset.
992
1042
  # @param [String] description A user-friendly description of the
993
1043
  # dataset.
@@ -1326,9 +1376,7 @@ module Google
1326
1376
  # bigquery = Google::Cloud::Bigquery.new
1327
1377
  #
1328
1378
  # fourpm = bigquery.time 16, 0, 0
1329
- # data = bigquery.query "SELECT name " \
1330
- # "FROM `my_dataset.my_table`" \
1331
- # "WHERE time_of_date = @time",
1379
+ # data = bigquery.query "SELECT name FROM `my_dataset.my_table` WHERE time_of_date = @time",
1332
1380
  # params: { time: fourpm }
1333
1381
  #
1334
1382
  # # Iterate over the first page of results
@@ -1344,9 +1392,7 @@ module Google
1344
1392
  # bigquery = Google::Cloud::Bigquery.new
1345
1393
  #
1346
1394
  # precise_time = bigquery.time 16, 35, 15.376541
1347
- # data = bigquery.query "SELECT name " \
1348
- # "FROM `my_dataset.my_table`" \
1349
- # "WHERE time_of_date >= @time",
1395
+ # data = bigquery.query "SELECT name FROM `my_dataset.my_table` WHERE time_of_date >= @time",
1350
1396
  # params: { time: precise_time }
1351
1397
  #
1352
1398
  # # Iterate over the first page of results
@@ -1524,8 +1570,8 @@ module Google
1524
1570
  # @param [Boolean] header Whether to print out a header row in table
1525
1571
  # exports. Default is `true`. Not applicable when extracting models.
1526
1572
  # @param [String] job_id A user-defined ID for the extract job. The ID
1527
- # must contain only letters (a-z, A-Z), numbers (0-9), underscores
1528
- # (_), or dashes (-). The maximum length is 1,024 characters. If
1573
+ # must contain only letters (`[A-Za-z]`), numbers (`[0-9]`), underscores
1574
+ # (`_`), or dashes (`-`). The maximum length is 1,024 characters. If
1529
1575
  # `job_id` is provided, then `prefix` will not be used.
1530
1576
  #
1531
1577
  # See [Generating a job
@@ -1534,8 +1580,8 @@ module Google
1534
1580
  # prepended to a generated value to produce a unique job ID. For
1535
1581
  # example, the prefix `daily_import_job_` can be given to generate a
1536
1582
  # job ID such as `daily_import_job_12vEDtMQ0mbp1Mo5Z7mzAFQJZazh`. The
1537
- # prefix must contain only letters (a-z, A-Z), numbers (0-9),
1538
- # underscores (_), or dashes (-). The maximum length of the entire ID
1583
+ # prefix must contain only letters (`[A-Za-z]`), numbers (`[0-9]`),
1584
+ # underscores (`_`), or dashes (`-`). The maximum length of the entire ID
1539
1585
  # is 1,024 characters. If `job_id` is provided, then `prefix` will not
1540
1586
  # be used.
1541
1587
  # @param [Hash] labels A hash of user-provided labels associated with
@@ -775,6 +775,8 @@ module Google
775
775
  updater = QueryJob::Updater.new service, req
776
776
  updater.set_params_and_types options[:params], options[:types] if options[:params]
777
777
  updater.create = options[:create]
778
+ updater.create_session = options[:create_session]
779
+ updater.session_id = options[:session_id] if options[:session_id]
778
780
  updater.write = options[:write]
779
781
  updater.table = options[:table]
780
782
  updater.dryrun = options[:dryrun]
@@ -1018,6 +1020,37 @@ module Google
1018
1020
  @gapi.configuration.query.create_disposition = Convert.create_disposition value
1019
1021
  end
1020
1022
 
1023
+ ##
1024
+ # Sets the create_session property. If true, creates a new session,
1025
+ # where session id will be a server generated random id. If false,
1026
+ # runs query with an existing {#session_id=}, otherwise runs query in
1027
+ # non-session mode. The default value is `false`.
1028
+ #
1029
+ # @param [Boolean] value The create_session property. The default
1030
+ # value is `false`.
1031
+ #
1032
+ # @!group Attributes
1033
+ def create_session= value
1034
+ @gapi.configuration.query.create_session = value
1035
+ end
1036
+
1037
+ ##
1038
+ # Sets the session ID for a query run in session mode. See {#create_session=}.
1039
+ #
1040
+ # @param [String] value The session ID. The default value is `nil`.
1041
+ #
1042
+ # @!group Attributes
1043
+ def session_id= value
1044
+ @gapi.configuration.query.connection_properties ||= []
1045
+ prop = @gapi.configuration.query.connection_properties.find { |cp| cp.key == "session_id" }
1046
+ if prop
1047
+ prop.value = value
1048
+ else
1049
+ prop = Google::Apis::BigqueryV2::ConnectionProperty.new key: "session_id", value: value
1050
+ @gapi.configuration.query.connection_properties << prop
1051
+ end
1052
+ end
1053
+
1021
1054
  ##
1022
1055
  # Sets the write disposition for when the query results table exists.
1023
1056
  #
@@ -116,8 +116,8 @@ module Google
116
116
  ##
117
117
  # A unique ID for this routine, without the project name.
118
118
  #
119
- # @return [String] The ID must contain only letters (a-z, A-Z), numbers (0-9), or underscores (_). The maximum
120
- # length is 256 characters.
119
+ # @return [String] The ID must contain only letters (`[A-Za-z]`), numbers (`[0-9]`), or underscores (`_`). The
120
+ # maximum length is 256 characters.
121
121
  #
122
122
  # @!group Attributes
123
123
  #