google-cloud-bigquery 1.42.0 → 1.49.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -300,14 +300,31 @@ module Google
300
300
  # At most 1 policy tag is currently allowed.
301
301
  # @param [Integer] max_length The maximum UTF-8 length of strings
302
302
  # allowed in the field.
303
- #
304
- def string name, description: nil, mode: :nullable, policy_tags: nil, max_length: nil
305
- add_field name,
306
- :string,
303
+ # @param default_value_expression [String] The default value of a field
304
+ # using a SQL expression. It can only be set for top level fields (columns).
305
+ # Use a struct or array expression to specify default value for the entire struct or
306
+ # array. The valid SQL expressions are:
307
+ # - Literals for all data types, including STRUCT and ARRAY.
308
+ # - The following functions:
309
+ # `CURRENT_TIMESTAMP`
310
+ # `CURRENT_TIME`
311
+ # `CURRENT_DATE`
312
+ # `CURRENT_DATETIME`
313
+ # `GENERATE_UUID`
314
+ # `RAND`
315
+ # `SESSION_USER`
316
+ # `ST_GEOPOINT`
317
+ # - Struct or array composed with the above allowed functions, for example:
318
+ # "[CURRENT_DATE(), DATE '2020-01-01'"]
319
+ #
320
+ def string name, description: nil, mode: :nullable, policy_tags: nil,
321
+ max_length: nil, default_value_expression: nil
322
+ add_field name, :string,
307
323
  description: description,
308
324
  mode: mode,
309
325
  policy_tags: policy_tags,
310
- max_length: max_length
326
+ max_length: max_length,
327
+ default_value_expression: default_value_expression
311
328
  end
312
329
 
313
330
  ##
@@ -325,9 +342,30 @@ module Google
325
342
  # single policy tag for the field. Policy tag identifiers are of
326
343
  # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
327
344
  # At most 1 policy tag is currently allowed.
328
- #
329
- def integer name, description: nil, mode: :nullable, policy_tags: nil
330
- add_field name, :integer, description: description, mode: mode, policy_tags: policy_tags
345
+ # @param default_value_expression [String] The default value of a field
346
+ # using a SQL expression. It can only be set for top level fields (columns).
347
+ # Use a struct or array expression to specify default value for the entire struct or
348
+ # array. The valid SQL expressions are:
349
+ # - Literals for all data types, including STRUCT and ARRAY.
350
+ # - The following functions:
351
+ # `CURRENT_TIMESTAMP`
352
+ # `CURRENT_TIME`
353
+ # `CURRENT_DATE`
354
+ # `CURRENT_DATETIME`
355
+ # `GENERATE_UUID`
356
+ # `RAND`
357
+ # `SESSION_USER`
358
+ # `ST_GEOPOINT`
359
+ # - Struct or array composed with the above allowed functions, for example:
360
+ # "[CURRENT_DATE(), DATE '2020-01-01'"]
361
+ #
362
+ def integer name, description: nil, mode: :nullable,
363
+ policy_tags: nil, default_value_expression: nil
364
+ add_field name, :integer,
365
+ description: description,
366
+ mode: mode,
367
+ policy_tags: policy_tags,
368
+ default_value_expression: default_value_expression
331
369
  end
332
370
 
333
371
  ##
@@ -345,9 +383,30 @@ module Google
345
383
  # single policy tag for the field. Policy tag identifiers are of
346
384
  # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
347
385
  # At most 1 policy tag is currently allowed.
348
- #
349
- def float name, description: nil, mode: :nullable, policy_tags: nil
350
- add_field name, :float, description: description, mode: mode, policy_tags: policy_tags
386
+ # @param default_value_expression [String] The default value of a field
387
+ # using a SQL expression. It can only be set for top level fields (columns).
388
+ # Use a struct or array expression to specify default value for the entire struct or
389
+ # array. The valid SQL expressions are:
390
+ # - Literals for all data types, including STRUCT and ARRAY.
391
+ # - The following functions:
392
+ # `CURRENT_TIMESTAMP`
393
+ # `CURRENT_TIME`
394
+ # `CURRENT_DATE`
395
+ # `CURRENT_DATETIME`
396
+ # `GENERATE_UUID`
397
+ # `RAND`
398
+ # `SESSION_USER`
399
+ # `ST_GEOPOINT`
400
+ # - Struct or array composed with the above allowed functions, for example:
401
+ # "[CURRENT_DATE(), DATE '2020-01-01'"]
402
+ #
403
+ def float name, description: nil, mode: :nullable,
404
+ policy_tags: nil, default_value_expression: nil
405
+ add_field name, :float,
406
+ description: description,
407
+ mode: mode,
408
+ policy_tags: policy_tags,
409
+ default_value_expression: default_value_expression
351
410
  end
352
411
 
353
412
  ##
@@ -386,15 +445,32 @@ module Google
386
445
  # must be: `1 ≤ (precision - scale) ≤ 29`. Values for scale must
387
446
  # be: `0 ≤ scale ≤ 9`. If the scale value is set, the precision
388
447
  # value must be set as well.
389
- #
390
- def numeric name, description: nil, mode: :nullable, policy_tags: nil, precision: nil, scale: nil
391
- add_field name,
392
- :numeric,
448
+ # @param default_value_expression [String] The default value of a field
449
+ # using a SQL expression. It can only be set for top level fields (columns).
450
+ # Use a struct or array expression to specify default value for the entire struct or
451
+ # array. The valid SQL expressions are:
452
+ # - Literals for all data types, including STRUCT and ARRAY.
453
+ # - The following functions:
454
+ # `CURRENT_TIMESTAMP`
455
+ # `CURRENT_TIME`
456
+ # `CURRENT_DATE`
457
+ # `CURRENT_DATETIME`
458
+ # `GENERATE_UUID`
459
+ # `RAND`
460
+ # `SESSION_USER`
461
+ # `ST_GEOPOINT`
462
+ # - Struct or array composed with the above allowed functions, for example:
463
+ # "[CURRENT_DATE(), DATE '2020-01-01'"]
464
+ #
465
+ def numeric name, description: nil, mode: :nullable, policy_tags: nil,
466
+ precision: nil, scale: nil, default_value_expression: nil
467
+ add_field name, :numeric,
393
468
  description: description,
394
469
  mode: mode,
395
470
  policy_tags: policy_tags,
396
471
  precision: precision,
397
- scale: scale
472
+ scale: scale,
473
+ default_value_expression: default_value_expression
398
474
  end
399
475
 
400
476
  ##
@@ -433,15 +509,32 @@ module Google
433
509
  # must be: `1 ≤ (precision - scale) ≤ 38`. Values for scale must
434
510
  # be: `0 ≤ scale ≤ 38`. If the scale value is set, the precision
435
511
  # value must be set as well.
436
- #
437
- def bignumeric name, description: nil, mode: :nullable, policy_tags: nil, precision: nil, scale: nil
438
- add_field name,
439
- :bignumeric,
512
+ # @param default_value_expression [String] The default value of a field
513
+ # using a SQL expression. It can only be set for top level fields (columns).
514
+ # Use a struct or array expression to specify default value for the entire struct or
515
+ # array. The valid SQL expressions are:
516
+ # - Literals for all data types, including STRUCT and ARRAY.
517
+ # - The following functions:
518
+ # `CURRENT_TIMESTAMP`
519
+ # `CURRENT_TIME`
520
+ # `CURRENT_DATE`
521
+ # `CURRENT_DATETIME`
522
+ # `GENERATE_UUID`
523
+ # `RAND`
524
+ # `SESSION_USER`
525
+ # `ST_GEOPOINT`
526
+ # - Struct or array composed with the above allowed functions, for example:
527
+ # "[CURRENT_DATE(), DATE '2020-01-01'"]
528
+ #
529
+ def bignumeric name, description: nil, mode: :nullable, policy_tags: nil,
530
+ precision: nil, scale: nil, default_value_expression: nil
531
+ add_field name, :bignumeric,
440
532
  description: description,
441
533
  mode: mode,
442
534
  policy_tags: policy_tags,
443
535
  precision: precision,
444
- scale: scale
536
+ scale: scale,
537
+ default_value_expression: default_value_expression
445
538
  end
446
539
 
447
540
  ##
@@ -459,9 +552,30 @@ module Google
459
552
  # single policy tag for the field. Policy tag identifiers are of
460
553
  # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
461
554
  # At most 1 policy tag is currently allowed.
462
- #
463
- def boolean name, description: nil, mode: :nullable, policy_tags: nil
464
- add_field name, :boolean, description: description, mode: mode, policy_tags: policy_tags
555
+ # @param default_value_expression [String] The default value of a field
556
+ # using a SQL expression. It can only be set for top level fields (columns).
557
+ # Use a struct or array expression to specify default value for the entire struct or
558
+ # array. The valid SQL expressions are:
559
+ # - Literals for all data types, including STRUCT and ARRAY.
560
+ # - The following functions:
561
+ # `CURRENT_TIMESTAMP`
562
+ # `CURRENT_TIME`
563
+ # `CURRENT_DATE`
564
+ # `CURRENT_DATETIME`
565
+ # `GENERATE_UUID`
566
+ # `RAND`
567
+ # `SESSION_USER`
568
+ # `ST_GEOPOINT`
569
+ # - Struct or array composed with the above allowed functions, for example:
570
+ # "[CURRENT_DATE(), DATE '2020-01-01'"]
571
+ #
572
+ def boolean name, description: nil, mode: :nullable, policy_tags: nil,
573
+ default_value_expression: nil
574
+ add_field name, :boolean,
575
+ description: description,
576
+ mode: mode,
577
+ policy_tags: policy_tags,
578
+ default_value_expression: default_value_expression
465
579
  end
466
580
 
467
581
  ##
@@ -481,9 +595,31 @@ module Google
481
595
  # At most 1 policy tag is currently allowed.
482
596
  # @param [Integer] max_length The maximum the maximum number of
483
597
  # bytes in the field.
484
- #
485
- def bytes name, description: nil, mode: :nullable, policy_tags: nil, max_length: nil
486
- add_field name, :bytes, description: description, mode: mode, policy_tags: policy_tags, max_length: max_length
598
+ # @param default_value_expression [String] The default value of a field
599
+ # using a SQL expression. It can only be set for top level fields (columns).
600
+ # Use a struct or array expression to specify default value for the entire struct or
601
+ # array. The valid SQL expressions are:
602
+ # - Literals for all data types, including STRUCT and ARRAY.
603
+ # - The following functions:
604
+ # `CURRENT_TIMESTAMP`
605
+ # `CURRENT_TIME`
606
+ # `CURRENT_DATE`
607
+ # `CURRENT_DATETIME`
608
+ # `GENERATE_UUID`
609
+ # `RAND`
610
+ # `SESSION_USER`
611
+ # `ST_GEOPOINT`
612
+ # - Struct or array composed with the above allowed functions, for example:
613
+ # "[CURRENT_DATE(), DATE '2020-01-01'"]
614
+ #
615
+ def bytes name, description: nil, mode: :nullable,
616
+ policy_tags: nil, max_length: nil, default_value_expression: nil
617
+ add_field name, :bytes,
618
+ description: description,
619
+ mode: mode,
620
+ policy_tags: policy_tags,
621
+ max_length: max_length,
622
+ default_value_expression: default_value_expression
487
623
  end
488
624
 
489
625
  ##
@@ -501,9 +637,30 @@ module Google
501
637
  # single policy tag for the field. Policy tag identifiers are of
502
638
  # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
503
639
  # At most 1 policy tag is currently allowed.
504
- #
505
- def timestamp name, description: nil, mode: :nullable, policy_tags: nil
506
- add_field name, :timestamp, description: description, mode: mode, policy_tags: policy_tags
640
+ # @param default_value_expression [String] The default value of a field
641
+ # using a SQL expression. It can only be set for top level fields (columns).
642
+ # Use a struct or array expression to specify default value for the entire struct or
643
+ # array. The valid SQL expressions are:
644
+ # - Literals for all data types, including STRUCT and ARRAY.
645
+ # - The following functions:
646
+ # `CURRENT_TIMESTAMP`
647
+ # `CURRENT_TIME`
648
+ # `CURRENT_DATE`
649
+ # `CURRENT_DATETIME`
650
+ # `GENERATE_UUID`
651
+ # `RAND`
652
+ # `SESSION_USER`
653
+ # `ST_GEOPOINT`
654
+ # - Struct or array composed with the above allowed functions, for example:
655
+ # "[CURRENT_DATE(), DATE '2020-01-01'"]
656
+ #
657
+ def timestamp name, description: nil, mode: :nullable,
658
+ policy_tags: nil, default_value_expression: nil
659
+ add_field name, :timestamp,
660
+ description: description,
661
+ mode: mode,
662
+ policy_tags: policy_tags,
663
+ default_value_expression: default_value_expression
507
664
  end
508
665
 
509
666
  ##
@@ -521,9 +678,30 @@ module Google
521
678
  # single policy tag for the field. Policy tag identifiers are of
522
679
  # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
523
680
  # At most 1 policy tag is currently allowed.
524
- #
525
- def time name, description: nil, mode: :nullable, policy_tags: nil
526
- add_field name, :time, description: description, mode: mode, policy_tags: policy_tags
681
+ # @param default_value_expression [String] The default value of a field
682
+ # using a SQL expression. It can only be set for top level fields (columns).
683
+ # Use a struct or array expression to specify default value for the entire struct or
684
+ # array. The valid SQL expressions are:
685
+ # - Literals for all data types, including STRUCT and ARRAY.
686
+ # - The following functions:
687
+ # `CURRENT_TIMESTAMP`
688
+ # `CURRENT_TIME`
689
+ # `CURRENT_DATE`
690
+ # `CURRENT_DATETIME`
691
+ # `GENERATE_UUID`
692
+ # `RAND`
693
+ # `SESSION_USER`
694
+ # `ST_GEOPOINT`
695
+ # - Struct or array composed with the above allowed functions, for example:
696
+ # "[CURRENT_DATE(), DATE '2020-01-01'"]
697
+ #
698
+ def time name, description: nil, mode: :nullable,
699
+ policy_tags: nil, default_value_expression: nil
700
+ add_field name, :time,
701
+ description: description,
702
+ mode: mode,
703
+ policy_tags: policy_tags,
704
+ default_value_expression: default_value_expression
527
705
  end
528
706
 
529
707
  ##
@@ -541,9 +719,30 @@ module Google
541
719
  # single policy tag for the field. Policy tag identifiers are of
542
720
  # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
543
721
  # At most 1 policy tag is currently allowed.
544
- #
545
- def datetime name, description: nil, mode: :nullable, policy_tags: nil
546
- add_field name, :datetime, description: description, mode: mode, policy_tags: policy_tags
722
+ # @param default_value_expression [String] The default value of a field
723
+ # using a SQL expression. It can only be set for top level fields (columns).
724
+ # Use a struct or array expression to specify default value for the entire struct or
725
+ # array. The valid SQL expressions are:
726
+ # - Literals for all data types, including STRUCT and ARRAY.
727
+ # - The following functions:
728
+ # `CURRENT_TIMESTAMP`
729
+ # `CURRENT_TIME`
730
+ # `CURRENT_DATE`
731
+ # `CURRENT_DATETIME`
732
+ # `GENERATE_UUID`
733
+ # `RAND`
734
+ # `SESSION_USER`
735
+ # `ST_GEOPOINT`
736
+ # - Struct or array composed with the above allowed functions, for example:
737
+ # "[CURRENT_DATE(), DATE '2020-01-01'"]
738
+ #
739
+ def datetime name, description: nil, mode: :nullable,
740
+ policy_tags: nil, default_value_expression: nil
741
+ add_field name, :datetime,
742
+ description: description,
743
+ mode: mode,
744
+ policy_tags: policy_tags,
745
+ default_value_expression: default_value_expression
547
746
  end
548
747
 
549
748
  ##
@@ -561,9 +760,30 @@ module Google
561
760
  # single policy tag for the field. Policy tag identifiers are of
562
761
  # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
563
762
  # At most 1 policy tag is currently allowed.
564
- #
565
- def date name, description: nil, mode: :nullable, policy_tags: nil
566
- add_field name, :date, description: description, mode: mode, policy_tags: policy_tags
763
+ # @param default_value_expression [String] The default value of a field
764
+ # using a SQL expression. It can only be set for top level fields (columns).
765
+ # Use a struct or array expression to specify default value for the entire struct or
766
+ # array. The valid SQL expressions are:
767
+ # - Literals for all data types, including STRUCT and ARRAY.
768
+ # - The following functions:
769
+ # `CURRENT_TIMESTAMP`
770
+ # `CURRENT_TIME`
771
+ # `CURRENT_DATE`
772
+ # `CURRENT_DATETIME`
773
+ # `GENERATE_UUID`
774
+ # `RAND`
775
+ # `SESSION_USER`
776
+ # `ST_GEOPOINT`
777
+ # - Struct or array composed with the above allowed functions, for example:
778
+ # "[CURRENT_DATE(), DATE '2020-01-01'"]
779
+ #
780
+ def date name, description: nil, mode: :nullable,
781
+ policy_tags: nil, default_value_expression: nil
782
+ add_field name, :date,
783
+ description: description,
784
+ mode: mode,
785
+ policy_tags: policy_tags,
786
+ default_value_expression: default_value_expression
567
787
  end
568
788
 
569
789
  ##
@@ -583,9 +803,73 @@ module Google
583
803
  # single policy tag for the field. Policy tag identifiers are of
584
804
  # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
585
805
  # At most 1 policy tag is currently allowed.
806
+ # @param default_value_expression [String] The default value of a field
807
+ # using a SQL expression. It can only be set for top level fields (columns).
808
+ # Use a struct or array expression to specify default value for the entire struct or
809
+ # array. The valid SQL expressions are:
810
+ # - Literals for all data types, including STRUCT and ARRAY.
811
+ # - The following functions:
812
+ # `CURRENT_TIMESTAMP`
813
+ # `CURRENT_TIME`
814
+ # `CURRENT_DATE`
815
+ # `CURRENT_DATETIME`
816
+ # `GENERATE_UUID`
817
+ # `RAND`
818
+ # `SESSION_USER`
819
+ # `ST_GEOPOINT`
820
+ # - Struct or array composed with the above allowed functions, for example:
821
+ # "[CURRENT_DATE(), DATE '2020-01-01'"]
822
+ #
823
+ def geography name, description: nil, mode: :nullable,
824
+ policy_tags: nil, default_value_expression: nil
825
+ add_field name, :geography,
826
+ description: description,
827
+ mode: mode,
828
+ policy_tags: policy_tags,
829
+ default_value_expression: default_value_expression
830
+ end
831
+
832
+ ##
833
+ # Adds a JSON field to the schema.
586
834
  #
587
- def geography name, description: nil, mode: :nullable, policy_tags: nil
588
- add_field name, :geography, description: description, mode: mode, policy_tags: policy_tags
835
+ # @see https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#json_type
836
+ #
837
+ # @param [String] name The field name. The name must contain only
838
+ # letters (`[A-Za-z]`), numbers (`[0-9]`), or underscores (`_`), and must
839
+ # start with a letter or underscore. The maximum length is 128
840
+ # characters.
841
+ # @param [String] description A description of the field.
842
+ # @param [Symbol] mode The field's mode. The possible values are
843
+ # `:nullable`, `:required`, and `:repeated`. The default value is
844
+ # `:nullable`.
845
+ # @param [Array<String>, String] policy_tags The policy tag list or
846
+ # single policy tag for the field. Policy tag identifiers are of
847
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
848
+ # At most 1 policy tag is currently allowed.
849
+ # @param default_value_expression [String] The default value of a field
850
+ # using a SQL expression. It can only be set for top level fields (columns).
851
+ # Use a struct or array expression to specify default value for the entire struct or
852
+ # array. The valid SQL expressions are:
853
+ # - Literals for all data types, including STRUCT and ARRAY.
854
+ # - The following functions:
855
+ # `CURRENT_TIMESTAMP`
856
+ # `CURRENT_TIME`
857
+ # `CURRENT_DATE`
858
+ # `CURRENT_DATETIME`
859
+ # `GENERATE_UUID`
860
+ # `RAND`
861
+ # `SESSION_USER`
862
+ # `ST_GEOPOINT`
863
+ # - Struct or array composed with the above allowed functions, for example:
864
+ # "[CURRENT_DATE(), DATE '2020-01-01'"]
865
+ #
866
+ def json name, description: nil, mode: :nullable,
867
+ policy_tags: nil, default_value_expression: nil
868
+ add_field name, :json,
869
+ description: description,
870
+ mode: mode,
871
+ policy_tags: policy_tags,
872
+ default_value_expression: default_value_expression
589
873
  end
590
874
 
591
875
  ##
@@ -603,6 +887,23 @@ module Google
603
887
  # @param [Symbol] mode The field's mode. The possible values are
604
888
  # `:nullable`, `:required`, and `:repeated`. The default value is
605
889
  # `:nullable`.
890
+ # @param default_value_expression [String] The default value of a field
891
+ # using a SQL expression. It can only be set for top level fields (columns).
892
+ # Use a struct or array expression to specify default value for the entire struct or
893
+ # array. The valid SQL expressions are:
894
+ # - Literals for all data types, including STRUCT and ARRAY.
895
+ # - The following functions:
896
+ # `CURRENT_TIMESTAMP`
897
+ # `CURRENT_TIME`
898
+ # `CURRENT_DATE`
899
+ # `CURRENT_DATETIME`
900
+ # `GENERATE_UUID`
901
+ # `RAND`
902
+ # `SESSION_USER`
903
+ # `ST_GEOPOINT`
904
+ # - Struct or array composed with the above allowed functions, for example:
905
+ # "[CURRENT_DATE(), DATE '2020-01-01'"]
906
+ #
606
907
  # @yield [field] a block for setting the nested record's schema
607
908
  # @yieldparam [Field] field the object accepting the
608
909
  # nested schema
@@ -622,11 +923,15 @@ module Google
622
923
  # end
623
924
  # end
624
925
  #
625
- def record name, description: nil, mode: nil
926
+ def record name, description: nil, mode: nil,
927
+ default_value_expression: nil
626
928
  # TODO: do we need to raise if no block was given?
627
929
  raise ArgumentError, "a block is required" unless block_given?
628
930
 
629
- nested_field = add_field name, :record, description: description, mode: mode
931
+ nested_field = add_field name, :record,
932
+ description: description,
933
+ mode: mode,
934
+ default_value_expression: default_value_expression
630
935
  yield nested_field
631
936
  nested_field
632
937
  end
@@ -675,7 +980,8 @@ module Google
675
980
  policy_tags: nil,
676
981
  max_length: nil,
677
982
  precision: nil,
678
- scale: nil
983
+ scale: nil,
984
+ default_value_expression: nil
679
985
  frozen_check!
680
986
 
681
987
  new_gapi = Google::Apis::BigqueryV2::TableFieldSchema.new(
@@ -692,6 +998,7 @@ module Google
692
998
  new_gapi.max_length = max_length if max_length
693
999
  new_gapi.precision = precision if precision
694
1000
  new_gapi.scale = scale if scale
1001
+ new_gapi.default_value_expression = default_value_expression if default_value_expression
695
1002
  # Remove any existing field of this name
696
1003
  @gapi.fields ||= []
697
1004
  @gapi.fields.reject! { |f| f.name == new_gapi.name }
@@ -41,15 +41,26 @@ module Google
41
41
  # @private
42
42
  attr_reader :retries, :timeout, :host
43
43
 
44
+ # @private
45
+ def universe_domain
46
+ service.universe_domain
47
+ end
48
+
44
49
  ##
45
50
  # Creates a new Service instance.
46
- def initialize project, credentials, retries: nil, timeout: nil, host: nil, quota_project: nil
51
+ def initialize project, credentials,
52
+ retries: nil,
53
+ timeout: nil,
54
+ host: nil,
55
+ quota_project: nil,
56
+ universe_domain: nil
47
57
  @project = project
48
58
  @credentials = credentials
49
59
  @retries = retries
50
60
  @timeout = timeout
51
61
  @host = host
52
62
  @quota_project = quota_project
63
+ @universe_domain = universe_domain
53
64
  end
54
65
 
55
66
  def service
@@ -69,7 +80,14 @@ module Google
69
80
  service.request_options.query["prettyPrint"] = false
70
81
  service.request_options.quota_project = @quota_project if @quota_project
71
82
  service.authorization = @credentials.client
83
+ service.universe_domain = @universe_domain
72
84
  service.root_url = host if host
85
+ begin
86
+ service.verify_universe_domain!
87
+ rescue Google::Apis::UniverseDomainError => e
88
+ # TODO: Create a Google::Cloud::Error subclass for this.
89
+ raise Google::Cloud::Error, e.message
90
+ end
73
91
  service
74
92
  end
75
93
  end
@@ -490,7 +508,7 @@ module Google
490
508
  project_id: m["prj"],
491
509
  dataset_id: m["dts"],
492
510
  table_id: m["tbl"]
493
- }.delete_if { |_, v| v.nil? }
511
+ }.compact
494
512
  str_table_ref_hash = default_ref.to_h.merge str_table_ref_hash
495
513
  ref = Google::Apis::BigqueryV2::TableReference.new(**str_table_ref_hash)
496
514
  validate_table_ref ref
@@ -506,7 +524,7 @@ module Google
506
524
  params = {
507
525
  dataset: Google::Apis::BigqueryV2::DatasetReference.new(**dataset_hash),
508
526
  target_types: dataset_hash[:target_types]
509
- }.delete_if { |_, v| v.nil? }
527
+ }.compact
510
528
  Google::Apis::BigqueryV2::DatasetAccessEntry.new(**params)
511
529
  end
512
530
 
@@ -540,13 +558,15 @@ module Google
540
558
  def dataset_ref_from dts, pjt = nil
541
559
  return nil if dts.nil?
542
560
  if dts.respond_to? :dataset_id
561
+ pjt ||= dts.project_id || @project
543
562
  Google::Apis::BigqueryV2::DatasetReference.new(
544
- project_id: (pjt || dts.project_id || @project),
563
+ project_id: pjt,
545
564
  dataset_id: dts.dataset_id
546
565
  )
547
566
  else
567
+ pjt ||= @project
548
568
  Google::Apis::BigqueryV2::DatasetReference.new(
549
- project_id: (pjt || @project),
569
+ project_id: pjt,
550
570
  dataset_id: dts
551
571
  )
552
572
  end
@@ -111,6 +111,7 @@ module Google
111
111
  # | `DATETIME` | `DateTime` | `DATETIME` does not support time zone. |
112
112
  # | `DATE` | `Date` | |
113
113
  # | `GEOGRAPHY` | `String` | |
114
+ # | `JSON` | `String` (Stringified JSON) | String, as JSON does not have a schema to verify. |
114
115
  # | `TIMESTAMP` | `Time` | |
115
116
  # | `TIME` | `Google::Cloud::BigQuery::Time` | |
116
117
  # | `BYTES` | `File`, `IO`, `StringIO`, or similar | |