google-cloud-bigquery 1.45.0 → 1.50.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '03038d9349c8061b4259b0d954f722cbe1cbe52da5126b1684729bd23ab771ac'
4
- data.tar.gz: d56ca5d84af79507553d866be87cf0b38ac14341c00b94fddf71ce6a5275171e
3
+ metadata.gz: 9e67dfdf938a25ab1800e16136f9d3bc9e1253eb16a89cdfb6437b835148b971
4
+ data.tar.gz: f12d0a0281546ad8830602bd8c8cfda0017bfa6ddf326abe9875e9ebaaeb7165
5
5
  SHA512:
6
- metadata.gz: aacd27d7aa0e1301009bacee0569ed5f20280c4f0f7e025acfa0a99251874ee1220079ac2b94478ebb0664262c7ce5720e3df59c0cde71e52adc70ab1e05c766
7
- data.tar.gz: 7bb66689b79db32fdc6e1183f365107f99b95272dbca2329acbbb5520e1516da3310ce317a364d19a18cff29d304943d1350f61cc107ee9d6256e8d02855f64e
6
+ metadata.gz: 27031288672aa253d5250fecc387cfce57cddc16a82bc43ae8b09fef1c38a32f31df8884815bb5f65d10a701cbefc0c7a220295fef87088972199fdd75cce272
7
+ data.tar.gz: a9d57161072a53ddbc488b9a8f4d837b82869d234510d7a18637f50534a39964214a022164b74639505c9116d21f38ec55bd856d2a8f578696cfc0e119c043ad
data/CHANGELOG.md CHANGED
@@ -1,5 +1,53 @@
1
1
  # Release History
2
2
 
3
+ ### 1.50.0 (2024-06-27)
4
+
5
+ #### Features
6
+
7
+ * add method in load_job to set column name character map ([#26135](https://github.com/googleapis/google-cloud-ruby/issues/26135))
8
+
9
+ ### 1.49.1 (2024-06-05)
10
+
11
+ #### Bug Fixes
12
+
13
+ * Added bigdecimal to the gem dependencies ([#26012](https://github.com/googleapis/google-cloud-ruby/issues/26012))
14
+
15
+ ### 1.49.0 (2024-03-10)
16
+
17
+ #### Features
18
+
19
+ * Update minimum supported Ruby version to 2.7 ([#25298](https://github.com/googleapis/google-cloud-ruby/issues/25298))
20
+
21
+ ### 1.48.1 (2024-02-10)
22
+
23
+ #### Documentation
24
+
25
+ * Correct an example snippet related to storage_billing_model ([#24796](https://github.com/googleapis/google-cloud-ruby/issues/24796))
26
+
27
+ ### 1.48.0 (2024-02-08)
28
+
29
+ #### Features
30
+
31
+ * Support accessing storage_ billing_model field in a dataset ([#24755](https://github.com/googleapis/google-cloud-ruby/issues/24755))
32
+
33
+ ### 1.47.0 (2024-02-05)
34
+
35
+ #### Features
36
+
37
+ * add json type support ([#24491](https://github.com/googleapis/google-cloud-ruby/issues/24491))
38
+
39
+ ### 1.46.1 (2024-01-26)
40
+
41
+ #### Bug Fixes
42
+
43
+ * Raise an error on mismatching universe domain ([#24485](https://github.com/googleapis/google-cloud-ruby/issues/24485))
44
+
45
+ ### 1.46.0 (2024-01-25)
46
+
47
+ #### Features
48
+
49
+ * Support for universe_domain ([#24448](https://github.com/googleapis/google-cloud-ruby/issues/24448))
50
+
3
51
  ### 1.45.0 (2023-09-25)
4
52
 
5
53
  #### Features
@@ -39,6 +39,7 @@ module Google
39
39
  # | `DATETIME` | `DateTime` | `DATETIME` does not support time zone. |
40
40
  # | `DATE` | `Date` | |
41
41
  # | `GEOGRAPHY` | `String` | |
42
+ # | `JSON` | `String` | String, as JSON does not have a schema to verify. |
42
43
  # | `TIMESTAMP` | `Time` | |
43
44
  # | `TIME` | `Google::Cloud::BigQuery::Time` | |
44
45
  # | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
@@ -72,7 +73,7 @@ module Google
72
73
  value[:v].map { |v| format_value v, field }
73
74
  elsif Hash === value[:v]
74
75
  format_row value[:v], field.fields
75
- elsif field.type == "STRING"
76
+ elsif field.type == "STRING" || field.type == "JSON" || field.type == "GEOGRAPHY"
76
77
  String value[:v]
77
78
  elsif field.type == "INTEGER"
78
79
  Integer value[:v]
@@ -102,8 +103,6 @@ module Google
102
103
  ::Time.parse("#{value[:v]} UTC").to_datetime
103
104
  elsif field.type == "DATE"
104
105
  Date.parse value[:v]
105
- elsif field.type == "GEOGRAPHY"
106
- String value[:v]
107
106
  else
108
107
  value[:v]
109
108
  end
@@ -311,6 +310,21 @@ module Google
311
310
  str
312
311
  end
313
312
 
313
+ ##
314
+ # Converts character map strings to API values.
315
+ #
316
+ # @return [String] API representation of character map.
317
+ def self.character_map mapping_version
318
+ val = {
319
+ "default" => "COLUMN_NAME_CHARACTER_MAP_UNSPECIFIED",
320
+ "strict" => "STRICT",
321
+ "v1" => "V1",
322
+ "v2" => "V2"
323
+ }[mapping_version.to_s.downcase]
324
+ return val unless val.nil?
325
+ mapping_version
326
+ end
327
+
314
328
  ##
315
329
  # Converts source format strings to API values.
316
330
  #
@@ -412,6 +412,56 @@ module Google
412
412
  patch_gapi! :default_encryption_configuration
413
413
  end
414
414
 
415
+ ##
416
+ # Gets the Storage Billing Model for the dataset.
417
+ #
418
+ # @see https://cloud.google.com/blog/products/data-analytics/new-bigquery-billing-model-helps-reduce-physical-storage-costs
419
+ #
420
+ # @return [String, nil] A string containing the storage billing model, or `nil`.
421
+ # Possible values of the string are `LOGICAL`, `PHYSICAL`.
422
+ # It returns `nil` if either the object is a reference (see {#reference?}),
423
+ # or if the storage billing model is unspecified.
424
+ #
425
+ # @example
426
+ #
427
+ # require "google/cloud/bigquery"
428
+ #
429
+ # bigquery = Google::Cloud::Bigquery.new
430
+ # dataset = bigquery.dataset "my_dataset"
431
+ #
432
+ # storage_billing_model = dataset.storage_billing_model
433
+ #
434
+ # @!group Attributes
435
+ #
436
+ def storage_billing_model
437
+ return nil if reference?
438
+ ensure_full_data!
439
+ @gapi.storage_billing_model
440
+ end
441
+
442
+ ##
443
+ # Sets the Storage Billing Model for the dataset.
444
+ #
445
+ # @see https://cloud.google.com/blog/products/data-analytics/new-bigquery-billing-model-helps-reduce-physical-storage-costs
446
+ #
447
+ # @param value [String] The new storage billing model. Accepted values
448
+ # are `LOGICAL` and `PHYSICAL`.
449
+ #
450
+ # @example
451
+ # require "google/cloud/bigquery"
452
+ #
453
+ # bigquery = Google::Cloud::Bigquery.new
454
+ # dataset = bigquery.dataset "my_dataset"
455
+ # dataset.storage_billing_model = "LOGICAL"
456
+ #
457
+ # @!group Attributes
458
+ #
459
+ def storage_billing_model= value
460
+ ensure_full_data!
461
+ @gapi.storage_billing_model = value
462
+ patch_gapi! :storage_billing_model
463
+ end
464
+
415
465
  ##
416
466
  # Retrieves the access rules for a Dataset. The rules can be updated
417
467
  # when passing a block, see {Dataset::Access} for all the methods
@@ -1180,6 +1230,7 @@ module Google
1180
1230
  # | `DATETIME` | `DateTime` | `DATETIME` does not support time zone. |
1181
1231
  # | `DATE` | `Date` | |
1182
1232
  # | `GEOGRAPHY` | `String` (WKT or GeoJSON) | NOT AUTOMATIC: Must be mapped using `types`, below.|
1233
+ # | `JSON` | `String` (Stringified JSON) | String, as JSON does not have a schema to verify. |
1183
1234
  # | `TIMESTAMP` | `Time` | |
1184
1235
  # | `TIME` | `Google::Cloud::BigQuery::Time` | |
1185
1236
  # | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
@@ -1206,6 +1257,7 @@ module Google
1206
1257
  # * `:DATETIME`
1207
1258
  # * `:DATE`
1208
1259
  # * `:GEOGRAPHY`
1260
+ # * `:JSON`
1209
1261
  # * `:TIMESTAMP`
1210
1262
  # * `:TIME`
1211
1263
  # * `:BYTES`
@@ -1585,6 +1637,7 @@ module Google
1585
1637
  # | `DATETIME` | `DateTime` | `DATETIME` does not support time zone. |
1586
1638
  # | `DATE` | `Date` | |
1587
1639
  # | `GEOGRAPHY` | `String` (WKT or GeoJSON) | NOT AUTOMATIC: Must be mapped using `types`, below.|
1640
+ # | `JSON` | `String` (Stringified JSON) | String, as JSON does not have a schema to verify. |
1588
1641
  # | `TIMESTAMP` | `Time` | |
1589
1642
  # | `TIME` | `Google::Cloud::BigQuery::Time` | |
1590
1643
  # | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
@@ -1611,6 +1664,7 @@ module Google
1611
1664
  # * `:DATETIME`
1612
1665
  # * `:DATE`
1613
1666
  # * `:GEOGRAPHY`
1667
+ # * `:JSON`
1614
1668
  # * `:TIMESTAMP`
1615
1669
  # * `:TIME`
1616
1670
  # * `:BYTES`
@@ -2553,6 +2607,7 @@ module Google
2553
2607
  # | `DATETIME` | `DateTime` | `DATETIME` does not support time zone. |
2554
2608
  # | `DATE` | `Date` | |
2555
2609
  # | `GEOGRAPHY` | `String` | |
2610
+ # | `JSON` | `String` (Stringified JSON) | String, as JSON does not have a schema to verify. |
2556
2611
  # | `TIMESTAMP` | `Time` | |
2557
2612
  # | `TIME` | `Google::Cloud::BigQuery::Time` | |
2558
2613
  # | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
@@ -1531,6 +1531,71 @@ module Google
1531
1531
  default_value_expression: default_value_expression
1532
1532
  end
1533
1533
 
1534
+ ##
1535
+ # Adds an json field to the schema.
1536
+ #
1537
+ # See {Schema#json}.
1538
+ # https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#json_type
1539
+ #
1540
+ # @param [String] name The field name. The name must contain only
1541
+ # letters (`[A-Za-z]`), numbers (`[0-9]`), or underscores (`_`), and must
1542
+ # start with a letter or underscore. The maximum length is 128
1543
+ # characters.
1544
+ # @param [String] description A description of the field.
1545
+ # @param [Symbol] mode The field's mode. The possible values are
1546
+ # `:nullable`, `:required`, and `:repeated`. The default value is
1547
+ # `:nullable`.
1548
+ # @param [Array<String>, String] policy_tags The policy tag list or
1549
+ # single policy tag for the field. Policy tag identifiers are of
1550
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
1551
+ # At most 1 policy tag is currently allowed.
1552
+ # @param default_value_expression [String] The default value of a field
1553
+ # using a SQL expression. It can only be set for top level fields (columns).
1554
+ # Use a struct or array expression to specify default value for the entire struct or
1555
+ # array. The valid SQL expressions are:
1556
+ # - Literals for all data types, including STRUCT and ARRAY.
1557
+ # - The following functions:
1558
+ # `CURRENT_TIMESTAMP`
1559
+ # `CURRENT_TIME`
1560
+ # `CURRENT_DATE`
1561
+ # `CURRENT_DATETIME`
1562
+ # `GENERATE_UUID`
1563
+ # `RAND`
1564
+ # `SESSION_USER`
1565
+ # `ST_GEOPOINT`
1566
+ # - Struct or array composed with the above allowed functions, for example:
1567
+ # "[CURRENT_DATE(), DATE '2020-01-01'"]
1568
+ #
1569
+ # @example
1570
+ # require "google/cloud/bigquery"
1571
+ #
1572
+ # bigquery = Google::Cloud::Bigquery.new
1573
+ # dataset = bigquery.dataset "my_dataset"
1574
+ # job = dataset.load_job "my_table", "gs://abc/file" do |schema|
1575
+ # schema.record "cities_lived", mode: :repeated do |cities_lived|
1576
+ # cities_lived.geography "location", mode: :required
1577
+ # cities_lived.integer "number_of_years", mode: :required
1578
+ # cities_lived.json "address", mode: :required
1579
+ # end
1580
+ # end
1581
+ #
1582
+ # @example Add field with default value.
1583
+ # require "google/cloud/bigquery"
1584
+ #
1585
+ # bigquery = Google::Cloud::Bigquery.new
1586
+ # dataset = bigquery.dataset "my_dataset"
1587
+ # job = dataset.load_job "my_table", "gs://abc/file" do |schema|
1588
+ # schema.json "person", default_value_expression: "JSON '{"name": "Alice", "age": 30}'"
1589
+ # end
1590
+ #
1591
+ # @!group Schema
1592
+ #
1593
+ def json name, description: nil, mode: :nullable, policy_tags: nil,
1594
+ default_value_expression: nil
1595
+ schema.json name, description: description, mode: mode, policy_tags: policy_tags,
1596
+ default_value_expression: default_value_expression
1597
+ end
1598
+
1534
1599
  ##
1535
1600
  # Adds a record field to the schema. A block must be passed describing
1536
1601
  # the nested fields of the record. For more information about nested
@@ -1662,6 +1727,24 @@ module Google
1662
1727
  @gapi.configuration.load.update! source_format: Convert.source_format(new_format)
1663
1728
  end
1664
1729
 
1730
+ ##
1731
+ # Sets the character map for column name conversion. The default value is `default`.
1732
+ #
1733
+ # The following values are supported:
1734
+ #
1735
+ # * `default`
1736
+ # * `strict`
1737
+ # * `v1`
1738
+ # * `v2`
1739
+ #
1740
+ # @param [String] new_character_map The new character map.
1741
+ #
1742
+ # @!group Attributes
1743
+ #
1744
+ def column_name_character_map= new_character_map
1745
+ @gapi.configuration.load.update! column_name_character_map: Convert.character_map(new_character_map)
1746
+ end
1747
+
1665
1748
  ##
1666
1749
  # Sets the create disposition.
1667
1750
  #
@@ -67,6 +67,15 @@ module Google
67
67
  @service = service
68
68
  end
69
69
 
70
+ ##
71
+ # The universe domain the client is connected to
72
+ #
73
+ # @return [String]
74
+ #
75
+ def universe_domain
76
+ service.universe_domain
77
+ end
78
+
70
79
  ##
71
80
  # The BigQuery project connected to.
72
81
  #
@@ -304,6 +313,7 @@ module Google
304
313
  # | `DATETIME` | `DateTime` | `DATETIME` does not support time zone. |
305
314
  # | `DATE` | `Date` | |
306
315
  # | `GEOGRAPHY` | `String` (WKT or GeoJSON) | NOT AUTOMATIC: Must be mapped using `types`, below.|
316
+ # | `JSON` | `String` (Stringified JSON) | String, as JSON does not have a schema to verify. |
307
317
  # | `TIMESTAMP` | `Time` | |
308
318
  # | `TIME` | `Google::Cloud::BigQuery::Time` | |
309
319
  # | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
@@ -330,6 +340,7 @@ module Google
330
340
  # * `:DATETIME`
331
341
  # * `:DATE`
332
342
  # * `:GEOGRAPHY`
343
+ # * `:JSON`
333
344
  # * `:TIMESTAMP`
334
345
  # * `:TIME`
335
346
  # * `:BYTES`
@@ -622,6 +633,7 @@ module Google
622
633
  create_session: nil,
623
634
  session_id: nil
624
635
  ensure_service!
636
+ project ||= self.project
625
637
  options = {
626
638
  params: params,
627
639
  types: types,
@@ -633,7 +645,7 @@ module Google
633
645
  write: write,
634
646
  dryrun: dryrun,
635
647
  dataset: dataset,
636
- project: (project || self.project),
648
+ project: project,
637
649
  standard_sql: standard_sql,
638
650
  legacy_sql: legacy_sql,
639
651
  large_results: large_results,
@@ -691,6 +703,7 @@ module Google
691
703
  # | `DATETIME` | `DateTime` | `DATETIME` does not support time zone. |
692
704
  # | `DATE` | `Date` | |
693
705
  # | `GEOGRAPHY` | `String` (WKT or GeoJSON) | NOT AUTOMATIC: Must be mapped using `types`, below.|
706
+ # | `JSON` | `String` (Stringified JSON) | String, as JSON does not have a schema to verify. |
694
707
  # | `TIMESTAMP` | `Time` | |
695
708
  # | `TIME` | `Google::Cloud::BigQuery::Time` | |
696
709
  # | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
@@ -717,6 +730,7 @@ module Google
717
730
  # * `:DATETIME`
718
731
  # * `:DATE`
719
732
  # * `:GEOGRAPHY`
733
+ # * `:JSON`
720
734
  # * `:TIMESTAMP`
721
735
  # * `:TIME`
722
736
  # * `:BYTES`
@@ -927,6 +927,7 @@ module Google
927
927
  # | `DATETIME` | `DateTime` | `DATETIME` does not support time zone. |
928
928
  # | `DATE` | `Date` | |
929
929
  # | `GEOGRAPHY` | `String` (WKT or GeoJSON) | NOT AUTOMATIC: Must be mapped using `types`. |
930
+ # | `JSON` | `String` (Stringified JSON) | String, as JSON does not have a schema to verify.|
930
931
  # | `TIMESTAMP` | `Time` | |
931
932
  # | `TIME` | `Google::Cloud::BigQuery::Time` | |
932
933
  # | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
@@ -964,6 +965,7 @@ module Google
964
965
  # | `DATETIME` | `DateTime` | `DATETIME` does not support time zone. |
965
966
  # | `DATE` | `Date` | |
966
967
  # | `GEOGRAPHY` | `String` (WKT or GeoJSON) | NOT AUTOMATIC: Must be mapped using `types`. |
968
+ # | `JSON` | `String` (Stringified JSON) | String, as JSON does not have a schema to verify.|
967
969
  # | `TIMESTAMP` | `Time` | |
968
970
  # | `TIME` | `Google::Cloud::BigQuery::Time` | |
969
971
  # | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
@@ -990,6 +992,7 @@ module Google
990
992
  # * `:DATETIME`
991
993
  # * `:DATE`
992
994
  # * `:GEOGRAPHY`
995
+ # * `:JSON`
993
996
  # * `:TIMESTAMP`
994
997
  # * `:TIME`
995
998
  # * `:BYTES`
@@ -52,6 +52,7 @@ module Google
52
52
  "GEOGRAPHY",
53
53
  "INTEGER",
54
54
  "INT64",
55
+ "JSON",
55
56
  "NUMERIC",
56
57
  "RECORD",
57
58
  "STRING",
@@ -98,6 +99,7 @@ module Google
98
99
  # * `FLOAT`
99
100
  # * `FLOAT64` (same as `FLOAT`)
100
101
  # * `GEOGRAPHY`
102
+ # * `JSON`
101
103
  # * `INTEGER`
102
104
  # * `INT64` (same as `INTEGER`)
103
105
  # * `NUMERIC`
@@ -125,6 +127,7 @@ module Google
125
127
  # * `FLOAT`
126
128
  # * `FLOAT64` (same as `FLOAT`)
127
129
  # * `GEOGRAPHY`
130
+ # * `JSON`
128
131
  # * `INTEGER`
129
132
  # * `INT64` (same as `INTEGER`)
130
133
  # * `NUMERIC`
@@ -456,6 +459,15 @@ module Google
456
459
  type == "GEOGRAPHY"
457
460
  end
458
461
 
462
+ ##
463
+ # Checks if the type of the field is `JSON`.
464
+ #
465
+ # @return [Boolean] `true` when `JSON`, `false` otherwise.
466
+ #
467
+ def json?
468
+ type == "JSON"
469
+ end
470
+
459
471
  ##
460
472
  # Checks if the type of the field is `RECORD`.
461
473
  #
@@ -893,6 +905,30 @@ module Google
893
905
  add_field name, :geography, description: description, mode: mode, policy_tags: policy_tags
894
906
  end
895
907
 
908
+ ##
909
+ # Adds a json field to the nested schema of a record field.
910
+ #
911
+ # https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#json_type
912
+ #
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
915
+ # start with a letter or underscore. The maximum length is 128
916
+ # characters.
917
+ # @param [String] description A description of the field.
918
+ # @param [Symbol] mode The field's mode. The possible values are
919
+ # `:nullable`, `:required`, and `:repeated`. The default value is
920
+ # `:nullable`.
921
+ # @param [Array<String>, String] policy_tags The policy tag list or
922
+ # single policy tag for the field. Policy tag identifiers are of
923
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
924
+ # At most 1 policy tag is currently allowed.
925
+ #
926
+ def json name, description: nil, mode: :nullable, policy_tags: nil
927
+ record_check!
928
+
929
+ add_field name, :json, description: description, mode: mode, policy_tags: policy_tags
930
+ end
931
+
896
932
  ##
897
933
  # Adds a record field to the nested schema of a record field. A block
898
934
  # must be passed describing the nested fields of the record. For more
@@ -829,6 +829,49 @@ module Google
829
829
  default_value_expression: default_value_expression
830
830
  end
831
831
 
832
+ ##
833
+ # Adds a JSON field to the schema.
834
+ #
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
873
+ end
874
+
832
875
  ##
833
876
  # Adds a record field to the schema. A block must be passed describing
834
877
  # the nested fields of the record. For more information about nested
@@ -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
@@ -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 | |
@@ -2648,6 +2648,7 @@ module Google
2648
2648
  # | `DATETIME` | `DateTime` | `DATETIME` does not support time zone. |
2649
2649
  # | `DATE` | `Date` | |
2650
2650
  # | `GEOGRAPHY` | `String` | Well-known text (WKT) or GeoJSON. |
2651
+ # | `JSON` | `String` (Stringified JSON) | String, as JSON does not have a schema to verify. |
2651
2652
  # | `TIMESTAMP` | `Time` | |
2652
2653
  # | `TIME` | `Google::Cloud::BigQuery::Time` | |
2653
2654
  # | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
@@ -4284,6 +4285,66 @@ module Google
4284
4285
  default_value_expression: default_value_expression
4285
4286
  end
4286
4287
 
4288
+ ##
4289
+ # Adds an json field to the schema.
4290
+ #
4291
+ # See {Schema#json}.
4292
+ # https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#json_type
4293
+ #
4294
+ # @param [String] name The field name. The name must contain only
4295
+ # letters (`[A-Za-z]`), numbers (`[0-9]`), or underscores (`_`), and must
4296
+ # start with a letter or underscore. The maximum length is 128
4297
+ # characters.
4298
+ # @param [String] description A description of the field.
4299
+ # @param [Symbol] mode The field's mode. The possible values are
4300
+ # `:nullable`, `:required`, and `:repeated`. The default value is
4301
+ # `:nullable`.
4302
+ # @param [Array<String>, String] policy_tags The policy tag list or
4303
+ # single policy tag for the field. Policy tag identifiers are of
4304
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
4305
+ # At most 1 policy tag is currently allowed.
4306
+ # @param default_value_expression [String] The default value of a field
4307
+ # using a SQL expression. It can only be set for top level fields (columns).
4308
+ # Use a struct or array expression to specify default value for the entire struct or
4309
+ # array. The valid SQL expressions are:
4310
+ # - Literals for all data types, including STRUCT and ARRAY.
4311
+ # - The following functions:
4312
+ # `CURRENT_TIMESTAMP`
4313
+ # `CURRENT_TIME`
4314
+ # `CURRENT_DATE`
4315
+ # `CURRENT_DATETIME`
4316
+ # `GENERATE_UUID`
4317
+ # `RAND`
4318
+ # `SESSION_USER`
4319
+ # `ST_GEOPOINT`
4320
+ # - Struct or array composed with the above allowed functions, for example:
4321
+ # "[CURRENT_DATE(), DATE '2020-01-01'"]
4322
+ #
4323
+ # @example
4324
+ # require "google/cloud/bigquery"
4325
+ #
4326
+ # bigquery = Google::Cloud::Bigquery.new
4327
+ # dataset = bigquery.dataset "my_dataset"
4328
+ # table = dataset.create_table "my_table" do |schema|
4329
+ # schema.json "person", mode: :required
4330
+ # end
4331
+ #
4332
+ # @example Add field with default value.
4333
+ # require "google/cloud/bigquery"
4334
+ #
4335
+ # bigquery = Google::Cloud::Bigquery.new
4336
+ # dataset = bigquery.dataset "my_dataset"
4337
+ # table = dataset.create_table "my_table" do |schema|
4338
+ # schema.json "person", default_value_expression: "JSON '{"name": "Alice", "age": 30}'"
4339
+ # end
4340
+ #
4341
+ # @!group Schema
4342
+ def json name, description: nil, mode: :nullable, policy_tags: nil,
4343
+ default_value_expression: nil
4344
+ schema.json name, description: description, mode: mode, policy_tags: policy_tags,
4345
+ default_value_expression: default_value_expression
4346
+ end
4347
+
4287
4348
  ##
4288
4349
  # Adds a record field to the schema. A block must be passed describing
4289
4350
  # the nested fields of the record. For more information about nested
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Bigquery
19
- VERSION = "1.45.0".freeze
19
+ VERSION = "1.50.0".freeze
20
20
  end
21
21
  end
22
22
  end
@@ -67,12 +67,13 @@ module Google
67
67
  # table = dataset.table "my_table"
68
68
  #
69
69
  def self.new project_id: nil, credentials: nil, scope: nil, retries: nil, timeout: nil, endpoint: nil,
70
- project: nil, keyfile: nil
70
+ project: nil, keyfile: nil, universe_domain: nil
71
71
  scope ||= configure.scope
72
72
  retries ||= configure.retries
73
73
  timeout ||= configure.timeout
74
74
  endpoint ||= configure.endpoint
75
- credentials ||= (keyfile || default_credentials(scope: scope))
75
+ credentials ||= keyfile || default_credentials(scope: scope)
76
+ universe_domain ||= configure.universe_domain
76
77
 
77
78
  unless credentials.is_a? Google::Auth::Credentials
78
79
  credentials = Bigquery::Credentials.new credentials, scope: scope
@@ -84,7 +85,8 @@ module Google
84
85
  Bigquery::Project.new(
85
86
  Bigquery::Service.new(
86
87
  project_id, credentials,
87
- retries: retries, timeout: timeout, host: endpoint, quota_project: configure.quota_project
88
+ retries: retries, timeout: timeout, host: endpoint,
89
+ quota_project: configure.quota_project, universe_domain: universe_domain
88
90
  )
89
91
  )
90
92
  end
@@ -71,9 +71,11 @@ module Google
71
71
  # bigquery = gcloud.bigquery scope: platform_scope
72
72
  #
73
73
  def bigquery scope: nil, retries: nil, timeout: nil
74
+ retries ||= @retries
75
+ timeout ||= @timeout
74
76
  Google::Cloud.bigquery @project, @keyfile, scope: scope,
75
- retries: (retries || @retries),
76
- timeout: (timeout || @timeout)
77
+ retries: retries,
78
+ timeout: timeout
77
79
  end
78
80
 
79
81
  ##
@@ -140,4 +142,5 @@ Google::Cloud.configure.add_config! :bigquery do |config|
140
142
  config.add_field! :retries, nil, match: Integer
141
143
  config.add_field! :timeout, nil, match: Integer
142
144
  config.add_field! :endpoint, default_endpoint, match: String, allow_nil: true
145
+ config.add_field! :universe_domain, nil, match: String, allow_nil: true
143
146
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-bigquery
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.45.0
4
+ version: 1.50.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Moore
@@ -9,72 +9,24 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-09-25 00:00:00.000000000 Z
12
+ date: 2024-06-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: concurrent-ruby
16
- requirement: !ruby/object:Gem::Requirement
17
- requirements:
18
- - - "~>"
19
- - !ruby/object:Gem::Version
20
- version: '1.0'
21
- type: :runtime
22
- prerelease: false
23
- version_requirements: !ruby/object:Gem::Requirement
24
- requirements:
25
- - - "~>"
26
- - !ruby/object:Gem::Version
27
- version: '1.0'
28
- - !ruby/object:Gem::Dependency
29
- name: google-apis-bigquery_v2
15
+ name: bigdecimal
30
16
  requirement: !ruby/object:Gem::Requirement
31
17
  requirements:
32
18
  - - "~>"
33
19
  - !ruby/object:Gem::Version
34
- version: '0.1'
35
- type: :runtime
36
- prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - "~>"
40
- - !ruby/object:Gem::Version
41
- version: '0.1'
42
- - !ruby/object:Gem::Dependency
43
- name: googleauth
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - ">="
47
- - !ruby/object:Gem::Version
48
- version: 0.16.2
49
- - - "<"
50
- - !ruby/object:Gem::Version
51
- version: 2.a
52
- type: :runtime
53
- prerelease: false
54
- version_requirements: !ruby/object:Gem::Requirement
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- version: 0.16.2
59
- - - "<"
60
- - !ruby/object:Gem::Version
61
- version: 2.a
62
- - !ruby/object:Gem::Dependency
63
- name: google-cloud-core
64
- requirement: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '1.6'
20
+ version: '3.0'
69
21
  type: :runtime
70
22
  prerelease: false
71
23
  version_requirements: !ruby/object:Gem::Requirement
72
24
  requirements:
73
25
  - - "~>"
74
26
  - !ruby/object:Gem::Version
75
- version: '1.6'
27
+ version: '3.0'
76
28
  - !ruby/object:Gem::Dependency
77
- name: mini_mime
29
+ name: concurrent-ruby
78
30
  requirement: !ruby/object:Gem::Requirement
79
31
  requirements:
80
32
  - - "~>"
@@ -88,159 +40,75 @@ dependencies:
88
40
  - !ruby/object:Gem::Version
89
41
  version: '1.0'
90
42
  - !ruby/object:Gem::Dependency
91
- name: autotest-suffix
43
+ name: google-apis-bigquery_v2
92
44
  requirement: !ruby/object:Gem::Requirement
93
45
  requirements:
94
46
  - - "~>"
95
47
  - !ruby/object:Gem::Version
96
- version: '1.1'
97
- type: :development
48
+ version: '0.71'
49
+ type: :runtime
98
50
  prerelease: false
99
51
  version_requirements: !ruby/object:Gem::Requirement
100
52
  requirements:
101
53
  - - "~>"
102
54
  - !ruby/object:Gem::Version
103
- version: '1.1'
55
+ version: '0.71'
104
56
  - !ruby/object:Gem::Dependency
105
- name: google-cloud-data_catalog
57
+ name: google-apis-core
106
58
  requirement: !ruby/object:Gem::Requirement
107
59
  requirements:
108
60
  - - "~>"
109
61
  - !ruby/object:Gem::Version
110
- version: '1.2'
111
- type: :development
62
+ version: '0.13'
63
+ type: :runtime
112
64
  prerelease: false
113
65
  version_requirements: !ruby/object:Gem::Requirement
114
66
  requirements:
115
67
  - - "~>"
116
68
  - !ruby/object:Gem::Version
117
- version: '1.2'
69
+ version: '0.13'
118
70
  - !ruby/object:Gem::Dependency
119
- name: google-style
71
+ name: googleauth
120
72
  requirement: !ruby/object:Gem::Requirement
121
73
  requirements:
122
74
  - - "~>"
123
75
  - !ruby/object:Gem::Version
124
- version: 1.26.1
125
- type: :development
76
+ version: '1.9'
77
+ type: :runtime
126
78
  prerelease: false
127
79
  version_requirements: !ruby/object:Gem::Requirement
128
80
  requirements:
129
81
  - - "~>"
130
82
  - !ruby/object:Gem::Version
131
- version: 1.26.1
83
+ version: '1.9'
132
84
  - !ruby/object:Gem::Dependency
133
- name: minitest
85
+ name: google-cloud-core
134
86
  requirement: !ruby/object:Gem::Requirement
135
87
  requirements:
136
88
  - - "~>"
137
89
  - !ruby/object:Gem::Version
138
- version: '5.16'
139
- type: :development
90
+ version: '1.6'
91
+ type: :runtime
140
92
  prerelease: false
141
93
  version_requirements: !ruby/object:Gem::Requirement
142
94
  requirements:
143
95
  - - "~>"
144
96
  - !ruby/object:Gem::Version
145
- version: '5.16'
97
+ version: '1.6'
146
98
  - !ruby/object:Gem::Dependency
147
- name: minitest-autotest
99
+ name: mini_mime
148
100
  requirement: !ruby/object:Gem::Requirement
149
101
  requirements:
150
102
  - - "~>"
151
103
  - !ruby/object:Gem::Version
152
104
  version: '1.0'
153
- type: :development
105
+ type: :runtime
154
106
  prerelease: false
155
107
  version_requirements: !ruby/object:Gem::Requirement
156
108
  requirements:
157
109
  - - "~>"
158
110
  - !ruby/object:Gem::Version
159
111
  version: '1.0'
160
- - !ruby/object:Gem::Dependency
161
- name: minitest-focus
162
- requirement: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - "~>"
165
- - !ruby/object:Gem::Version
166
- version: '1.1'
167
- type: :development
168
- prerelease: false
169
- version_requirements: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - "~>"
172
- - !ruby/object:Gem::Version
173
- version: '1.1'
174
- - !ruby/object:Gem::Dependency
175
- name: minitest-rg
176
- requirement: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - "~>"
179
- - !ruby/object:Gem::Version
180
- version: '5.2'
181
- type: :development
182
- prerelease: false
183
- version_requirements: !ruby/object:Gem::Requirement
184
- requirements:
185
- - - "~>"
186
- - !ruby/object:Gem::Version
187
- version: '5.2'
188
- - !ruby/object:Gem::Dependency
189
- name: redcarpet
190
- requirement: !ruby/object:Gem::Requirement
191
- requirements:
192
- - - "~>"
193
- - !ruby/object:Gem::Version
194
- version: '3.0'
195
- type: :development
196
- prerelease: false
197
- version_requirements: !ruby/object:Gem::Requirement
198
- requirements:
199
- - - "~>"
200
- - !ruby/object:Gem::Version
201
- version: '3.0'
202
- - !ruby/object:Gem::Dependency
203
- name: simplecov
204
- requirement: !ruby/object:Gem::Requirement
205
- requirements:
206
- - - "~>"
207
- - !ruby/object:Gem::Version
208
- version: '0.18'
209
- type: :development
210
- prerelease: false
211
- version_requirements: !ruby/object:Gem::Requirement
212
- requirements:
213
- - - "~>"
214
- - !ruby/object:Gem::Version
215
- version: '0.18'
216
- - !ruby/object:Gem::Dependency
217
- name: yard
218
- requirement: !ruby/object:Gem::Requirement
219
- requirements:
220
- - - "~>"
221
- - !ruby/object:Gem::Version
222
- version: '0.9'
223
- type: :development
224
- prerelease: false
225
- version_requirements: !ruby/object:Gem::Requirement
226
- requirements:
227
- - - "~>"
228
- - !ruby/object:Gem::Version
229
- version: '0.9'
230
- - !ruby/object:Gem::Dependency
231
- name: yard-doctest
232
- requirement: !ruby/object:Gem::Requirement
233
- requirements:
234
- - - "~>"
235
- - !ruby/object:Gem::Version
236
- version: 0.1.13
237
- type: :development
238
- prerelease: false
239
- version_requirements: !ruby/object:Gem::Requirement
240
- requirements:
241
- - - "~>"
242
- - !ruby/object:Gem::Version
243
- version: 0.1.13
244
112
  description: google-cloud-bigquery is the official library for Google BigQuery.
245
113
  email:
246
114
  - mike@blowmage.com
@@ -314,14 +182,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
314
182
  requirements:
315
183
  - - ">="
316
184
  - !ruby/object:Gem::Version
317
- version: '2.6'
185
+ version: '2.7'
318
186
  required_rubygems_version: !ruby/object:Gem::Requirement
319
187
  requirements:
320
188
  - - ">="
321
189
  - !ruby/object:Gem::Version
322
190
  version: '0'
323
191
  requirements: []
324
- rubygems_version: 3.4.19
192
+ rubygems_version: 3.5.6
325
193
  signing_key:
326
194
  specification_version: 4
327
195
  summary: API Client library for Google BigQuery