google-cloud-bigquery 1.45.0 → 1.51.1
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 +4 -4
- data/CHANGELOG.md +63 -0
- data/lib/google/cloud/bigquery/convert.rb +17 -3
- data/lib/google/cloud/bigquery/dataset.rb +61 -5
- data/lib/google/cloud/bigquery/load_job.rb +83 -0
- data/lib/google/cloud/bigquery/project.rb +31 -6
- data/lib/google/cloud/bigquery/query_job.rb +3 -0
- data/lib/google/cloud/bigquery/schema/field.rb +36 -0
- data/lib/google/cloud/bigquery/schema.rb +43 -0
- data/lib/google/cloud/bigquery/service.rb +37 -8
- data/lib/google/cloud/bigquery/table/async_inserter.rb +3 -1
- data/lib/google/cloud/bigquery/table.rb +64 -6
- data/lib/google/cloud/bigquery/version.rb +1 -1
- data/lib/google/cloud/bigquery.rb +5 -3
- data/lib/google-cloud-bigquery.rb +5 -2
- metadata +26 -158
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22622b84cc452512e75c5ac091f5e71984f0832756f019c4db07b7a65630548d
|
4
|
+
data.tar.gz: 80e428c51bac81fcd01a5cd05be6524fadfede36242f6d0803aa20eaa00c3529
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 321176420b19fc2ffc9f49deb73d0445835d8a89842e82fb9f63d3420332ce6f93a9d3c17cc4fb601d11721dd998268214ef39e7fd9eedda17e6afd1fcf9e973
|
7
|
+
data.tar.gz: f16ab1999e2a3b8aeeb79072c7cbe36db0388550a11c0afed6a1774a6bcda02a9aba72f45ddb29cced5520a804008248b1656f3ddd92320c40b35590da623972
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,68 @@
|
|
1
1
|
# Release History
|
2
2
|
|
3
|
+
### 1.51.1 (2024-12-13)
|
4
|
+
|
5
|
+
#### Bug Fixes
|
6
|
+
|
7
|
+
* Allow inserts to a target dataset/table in another project ([#28097](https://github.com/googleapis/google-cloud-ruby/issues/28097))
|
8
|
+
|
9
|
+
### 1.51.0 (2024-12-04)
|
10
|
+
|
11
|
+
#### Features
|
12
|
+
|
13
|
+
* load jobs with dest tables in another project ([#27681](https://github.com/googleapis/google-cloud-ruby/issues/27681))
|
14
|
+
#### Bug Fixes
|
15
|
+
|
16
|
+
* remove reload! call on patch_table ([#27684](https://github.com/googleapis/google-cloud-ruby/issues/27684))
|
17
|
+
|
18
|
+
### 1.50.0 (2024-06-27)
|
19
|
+
|
20
|
+
#### Features
|
21
|
+
|
22
|
+
* add method in load_job to set column name character map ([#26135](https://github.com/googleapis/google-cloud-ruby/issues/26135))
|
23
|
+
|
24
|
+
### 1.49.1 (2024-06-05)
|
25
|
+
|
26
|
+
#### Bug Fixes
|
27
|
+
|
28
|
+
* Added bigdecimal to the gem dependencies ([#26012](https://github.com/googleapis/google-cloud-ruby/issues/26012))
|
29
|
+
|
30
|
+
### 1.49.0 (2024-03-10)
|
31
|
+
|
32
|
+
#### Features
|
33
|
+
|
34
|
+
* Update minimum supported Ruby version to 2.7 ([#25298](https://github.com/googleapis/google-cloud-ruby/issues/25298))
|
35
|
+
|
36
|
+
### 1.48.1 (2024-02-10)
|
37
|
+
|
38
|
+
#### Documentation
|
39
|
+
|
40
|
+
* Correct an example snippet related to storage_billing_model ([#24796](https://github.com/googleapis/google-cloud-ruby/issues/24796))
|
41
|
+
|
42
|
+
### 1.48.0 (2024-02-08)
|
43
|
+
|
44
|
+
#### Features
|
45
|
+
|
46
|
+
* Support accessing storage_ billing_model field in a dataset ([#24755](https://github.com/googleapis/google-cloud-ruby/issues/24755))
|
47
|
+
|
48
|
+
### 1.47.0 (2024-02-05)
|
49
|
+
|
50
|
+
#### Features
|
51
|
+
|
52
|
+
* add json type support ([#24491](https://github.com/googleapis/google-cloud-ruby/issues/24491))
|
53
|
+
|
54
|
+
### 1.46.1 (2024-01-26)
|
55
|
+
|
56
|
+
#### Bug Fixes
|
57
|
+
|
58
|
+
* Raise an error on mismatching universe domain ([#24485](https://github.com/googleapis/google-cloud-ruby/issues/24485))
|
59
|
+
|
60
|
+
### 1.46.0 (2024-01-25)
|
61
|
+
|
62
|
+
#### Features
|
63
|
+
|
64
|
+
* Support for universe_domain ([#24448](https://github.com/googleapis/google-cloud-ruby/issues/24448))
|
65
|
+
|
3
66
|
### 1.45.0 (2023-09-25)
|
4
67
|
|
5
68
|
#### 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
|
@@ -849,7 +899,7 @@ module Google
|
|
849
899
|
def table table_id, skip_lookup: nil, view: nil
|
850
900
|
ensure_service!
|
851
901
|
return Table.new_reference project_id, dataset_id, table_id, service if skip_lookup
|
852
|
-
gapi = service.
|
902
|
+
gapi = service.get_project_table project_id, dataset_id, table_id, metadata_view: view
|
853
903
|
Table.from_gapi gapi, service, metadata_view: view
|
854
904
|
rescue Google::Cloud::NotFoundError
|
855
905
|
nil
|
@@ -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`
|
@@ -2390,7 +2444,7 @@ module Google
|
|
2390
2444
|
#
|
2391
2445
|
def reload!
|
2392
2446
|
ensure_service!
|
2393
|
-
@gapi = service.
|
2447
|
+
@gapi = service.get_project_dataset project_id, dataset_id
|
2394
2448
|
@reference = nil
|
2395
2449
|
@exists = nil
|
2396
2450
|
self
|
@@ -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 | |
|
@@ -2755,7 +2810,7 @@ module Google
|
|
2755
2810
|
ensure_service!
|
2756
2811
|
|
2757
2812
|
# Get table, don't use Dataset#table which handles NotFoundError
|
2758
|
-
gapi = service.
|
2813
|
+
gapi = service.get_project_table project_id, dataset_id, table_id, metadata_view: view
|
2759
2814
|
table = Table.from_gapi gapi, service, metadata_view: view
|
2760
2815
|
# Get the AsyncInserter from the table
|
2761
2816
|
table.insert_async skip_invalid: skip_invalid,
|
@@ -2810,7 +2865,8 @@ module Google
|
|
2810
2865
|
ensure_service!
|
2811
2866
|
gapi = service.insert_tabledata dataset_id, table_id, rows, skip_invalid: skip_invalid,
|
2812
2867
|
ignore_unknown: ignore_unknown,
|
2813
|
-
insert_ids: insert_ids
|
2868
|
+
insert_ids: insert_ids,
|
2869
|
+
project_id: project_id
|
2814
2870
|
InsertResponse.from_gapi rows, gapi
|
2815
2871
|
end
|
2816
2872
|
|
@@ -2872,7 +2928,7 @@ module Google
|
|
2872
2928
|
configuration: Google::Apis::BigqueryV2::JobConfiguration.new(
|
2873
2929
|
load: Google::Apis::BigqueryV2::JobConfigurationLoad.new(
|
2874
2930
|
destination_table: Google::Apis::BigqueryV2::TableReference.new(
|
2875
|
-
project_id:
|
2931
|
+
project_id: project_id,
|
2876
2932
|
dataset_id: dataset_id,
|
2877
2933
|
table_id: table_id
|
2878
2934
|
)
|
@@ -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:
|
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`
|
@@ -1097,6 +1111,7 @@ module Google
|
|
1097
1111
|
# Note: This will work only for tables in _SESSION dataset
|
1098
1112
|
# else the property will be ignored by the backend.
|
1099
1113
|
# @param [string] session_id Session ID in which the load job must run.
|
1114
|
+
# @param [string] project_id Project ID where the destination table exists.
|
1100
1115
|
#
|
1101
1116
|
# @yield [updater] A block for setting the schema and other
|
1102
1117
|
# options for the destination table. The schema can be omitted if the
|
@@ -1124,10 +1139,10 @@ module Google
|
|
1124
1139
|
projection_fields: nil, jagged_rows: nil, quoted_newlines: nil, encoding: nil,
|
1125
1140
|
delimiter: nil, ignore_unknown: nil, max_bad_records: nil, quote: nil,
|
1126
1141
|
skip_leading: nil, schema: nil, job_id: nil, prefix: nil, labels: nil, autodetect: nil,
|
1127
|
-
null_marker: nil, dryrun: nil, create_session: nil, session_id: nil, &block
|
1142
|
+
null_marker: nil, dryrun: nil, create_session: nil, session_id: nil, project_id: nil, &block
|
1128
1143
|
ensure_service!
|
1129
1144
|
dataset_id ||= "_SESSION" unless create_session.nil? && session_id.nil?
|
1130
|
-
session_dataset = dataset dataset_id, skip_lookup: true
|
1145
|
+
session_dataset = dataset dataset_id, skip_lookup: true, project_id: project_id
|
1131
1146
|
table = session_dataset.table table_id, skip_lookup: true
|
1132
1147
|
table.load_job files,
|
1133
1148
|
format: format, create: create, write: write, projection_fields: projection_fields,
|
@@ -1362,6 +1377,7 @@ module Google
|
|
1362
1377
|
# object without verifying that the resource exists on the BigQuery
|
1363
1378
|
# service. Calls made on this object will raise errors if the resource
|
1364
1379
|
# does not exist. Default is `false`. Optional.
|
1380
|
+
# @param [String] project_id The GCP Project where the dataset lives.
|
1365
1381
|
#
|
1366
1382
|
# @return [Google::Cloud::Bigquery::Dataset, nil] Returns `nil` if the
|
1367
1383
|
# dataset does not exist.
|
@@ -1374,6 +1390,14 @@ module Google
|
|
1374
1390
|
# dataset = bigquery.dataset "my_dataset"
|
1375
1391
|
# puts dataset.name
|
1376
1392
|
#
|
1393
|
+
# @example
|
1394
|
+
# require "google/cloud/bigquery"
|
1395
|
+
#
|
1396
|
+
# bigquery = Google::Cloud::Bigquery.new
|
1397
|
+
#
|
1398
|
+
# dataset = bigquery.dataset "my_dataset", project_id: "another_project"
|
1399
|
+
# puts dataset.name
|
1400
|
+
#
|
1377
1401
|
# @example Avoid retrieving the dataset resource with `skip_lookup`:
|
1378
1402
|
# require "google/cloud/bigquery"
|
1379
1403
|
#
|
@@ -1381,10 +1405,11 @@ module Google
|
|
1381
1405
|
#
|
1382
1406
|
# dataset = bigquery.dataset "my_dataset", skip_lookup: true
|
1383
1407
|
#
|
1384
|
-
def dataset dataset_id, skip_lookup: nil
|
1408
|
+
def dataset dataset_id, skip_lookup: nil, project_id: nil
|
1385
1409
|
ensure_service!
|
1386
|
-
|
1387
|
-
|
1410
|
+
project_id ||= project
|
1411
|
+
return Dataset.new_reference project_id, dataset_id, service if skip_lookup
|
1412
|
+
gapi = service.get_project_dataset project_id, dataset_id
|
1388
1413
|
Dataset.from_gapi gapi, service
|
1389
1414
|
rescue Google::Cloud::NotFoundError
|
1390
1415
|
nil
|
@@ -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,
|
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
|
@@ -92,9 +110,15 @@ module Google
|
|
92
110
|
##
|
93
111
|
# Returns the dataset specified by datasetID.
|
94
112
|
def get_dataset dataset_id
|
113
|
+
get_project_dataset @project, dataset_id
|
114
|
+
end
|
115
|
+
|
116
|
+
##
|
117
|
+
# Gets the specified dataset resource by full dataset reference.
|
118
|
+
def get_project_dataset project_id, dataset_id
|
95
119
|
# The get operation is considered idempotent
|
96
120
|
execute backoff: true do
|
97
|
-
service.get_dataset
|
121
|
+
service.get_dataset project_id, dataset_id
|
98
122
|
end
|
99
123
|
end
|
100
124
|
|
@@ -233,15 +257,17 @@ module Google
|
|
233
257
|
end
|
234
258
|
end
|
235
259
|
|
236
|
-
def insert_tabledata dataset_id, table_id, rows, insert_ids: nil, ignore_unknown: nil,
|
260
|
+
def insert_tabledata dataset_id, table_id, rows, insert_ids: nil, ignore_unknown: nil,
|
261
|
+
skip_invalid: nil, project_id: nil
|
237
262
|
json_rows = Array(rows).map { |row| Convert.to_json_row row }
|
238
263
|
insert_tabledata_json_rows dataset_id, table_id, json_rows, insert_ids: insert_ids,
|
239
264
|
ignore_unknown: ignore_unknown,
|
240
|
-
skip_invalid: skip_invalid
|
265
|
+
skip_invalid: skip_invalid,
|
266
|
+
project_id: project_id
|
241
267
|
end
|
242
268
|
|
243
269
|
def insert_tabledata_json_rows dataset_id, table_id, json_rows, insert_ids: nil, ignore_unknown: nil,
|
244
|
-
skip_invalid: nil
|
270
|
+
skip_invalid: nil, project_id: nil
|
245
271
|
rows_and_ids = Array(json_rows).zip Array(insert_ids)
|
246
272
|
insert_rows = rows_and_ids.map do |json_row, insert_id|
|
247
273
|
if insert_id == :skip
|
@@ -262,9 +288,10 @@ module Google
|
|
262
288
|
}.to_json
|
263
289
|
|
264
290
|
# The insertAll with insertId operation is considered idempotent
|
291
|
+
project_id ||= @project
|
265
292
|
execute backoff: true do
|
266
293
|
service.insert_all_table_data(
|
267
|
-
|
294
|
+
project_id, dataset_id, table_id, insert_req,
|
268
295
|
options: { skip_serialization: true }
|
269
296
|
)
|
270
297
|
end
|
@@ -540,13 +567,15 @@ module Google
|
|
540
567
|
def dataset_ref_from dts, pjt = nil
|
541
568
|
return nil if dts.nil?
|
542
569
|
if dts.respond_to? :dataset_id
|
570
|
+
pjt ||= dts.project_id || @project
|
543
571
|
Google::Apis::BigqueryV2::DatasetReference.new(
|
544
|
-
project_id:
|
572
|
+
project_id: pjt,
|
545
573
|
dataset_id: dts.dataset_id
|
546
574
|
)
|
547
575
|
else
|
576
|
+
pjt ||= @project
|
548
577
|
Google::Apis::BigqueryV2::DatasetReference.new(
|
549
|
-
project_id:
|
578
|
+
project_id: pjt,
|
550
579
|
dataset_id: dts
|
551
580
|
)
|
552
581
|
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 | |
|
@@ -293,7 +294,8 @@ module Google
|
|
293
294
|
json_rows,
|
294
295
|
skip_invalid: @skip_invalid,
|
295
296
|
ignore_unknown: @ignore_unknown,
|
296
|
-
insert_ids: insert_ids
|
297
|
+
insert_ids: insert_ids,
|
298
|
+
project_id: @table.project_id
|
297
299
|
|
298
300
|
result = Result.new InsertResponse.from_gapi(orig_rows, insert_resp)
|
299
301
|
rescue StandardError => e
|
@@ -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 | |
|
@@ -2746,7 +2747,8 @@ module Google
|
|
2746
2747
|
rows,
|
2747
2748
|
skip_invalid: skip_invalid,
|
2748
2749
|
ignore_unknown: ignore_unknown,
|
2749
|
-
insert_ids: insert_ids
|
2750
|
+
insert_ids: insert_ids,
|
2751
|
+
project_id: project_id
|
2750
2752
|
InsertResponse.from_gapi rows, gapi
|
2751
2753
|
end
|
2752
2754
|
|
@@ -3060,10 +3062,6 @@ module Google
|
|
3060
3062
|
patch_gapi = Google::Apis::BigqueryV2::Table.new(**patch_args)
|
3061
3063
|
patch_gapi.etag = etag if etag
|
3062
3064
|
@gapi = service.patch_table dataset_id, table_id, patch_gapi
|
3063
|
-
|
3064
|
-
# TODO: restore original impl after acceptance test indicates that
|
3065
|
-
# service etag bug is fixed
|
3066
|
-
reload!
|
3067
3065
|
end
|
3068
3066
|
|
3069
3067
|
def ensure_job_succeeded! job
|
@@ -3084,7 +3082,7 @@ module Google
|
|
3084
3082
|
configuration: Google::Apis::BigqueryV2::JobConfiguration.new(
|
3085
3083
|
load: Google::Apis::BigqueryV2::JobConfigurationLoad.new(
|
3086
3084
|
destination_table: Google::Apis::BigqueryV2::TableReference.new(
|
3087
|
-
project_id:
|
3085
|
+
project_id: project_id,
|
3088
3086
|
dataset_id: dataset_id,
|
3089
3087
|
table_id: table_id
|
3090
3088
|
)
|
@@ -4284,6 +4282,66 @@ module Google
|
|
4284
4282
|
default_value_expression: default_value_expression
|
4285
4283
|
end
|
4286
4284
|
|
4285
|
+
##
|
4286
|
+
# Adds an json field to the schema.
|
4287
|
+
#
|
4288
|
+
# See {Schema#json}.
|
4289
|
+
# https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#json_type
|
4290
|
+
#
|
4291
|
+
# @param [String] name The field name. The name must contain only
|
4292
|
+
# letters (`[A-Za-z]`), numbers (`[0-9]`), or underscores (`_`), and must
|
4293
|
+
# start with a letter or underscore. The maximum length is 128
|
4294
|
+
# characters.
|
4295
|
+
# @param [String] description A description of the field.
|
4296
|
+
# @param [Symbol] mode The field's mode. The possible values are
|
4297
|
+
# `:nullable`, `:required`, and `:repeated`. The default value is
|
4298
|
+
# `:nullable`.
|
4299
|
+
# @param [Array<String>, String] policy_tags The policy tag list or
|
4300
|
+
# single policy tag for the field. Policy tag identifiers are of
|
4301
|
+
# the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
|
4302
|
+
# At most 1 policy tag is currently allowed.
|
4303
|
+
# @param default_value_expression [String] The default value of a field
|
4304
|
+
# using a SQL expression. It can only be set for top level fields (columns).
|
4305
|
+
# Use a struct or array expression to specify default value for the entire struct or
|
4306
|
+
# array. The valid SQL expressions are:
|
4307
|
+
# - Literals for all data types, including STRUCT and ARRAY.
|
4308
|
+
# - The following functions:
|
4309
|
+
# `CURRENT_TIMESTAMP`
|
4310
|
+
# `CURRENT_TIME`
|
4311
|
+
# `CURRENT_DATE`
|
4312
|
+
# `CURRENT_DATETIME`
|
4313
|
+
# `GENERATE_UUID`
|
4314
|
+
# `RAND`
|
4315
|
+
# `SESSION_USER`
|
4316
|
+
# `ST_GEOPOINT`
|
4317
|
+
# - Struct or array composed with the above allowed functions, for example:
|
4318
|
+
# "[CURRENT_DATE(), DATE '2020-01-01'"]
|
4319
|
+
#
|
4320
|
+
# @example
|
4321
|
+
# require "google/cloud/bigquery"
|
4322
|
+
#
|
4323
|
+
# bigquery = Google::Cloud::Bigquery.new
|
4324
|
+
# dataset = bigquery.dataset "my_dataset"
|
4325
|
+
# table = dataset.create_table "my_table" do |schema|
|
4326
|
+
# schema.json "person", mode: :required
|
4327
|
+
# end
|
4328
|
+
#
|
4329
|
+
# @example Add field with default value.
|
4330
|
+
# require "google/cloud/bigquery"
|
4331
|
+
#
|
4332
|
+
# bigquery = Google::Cloud::Bigquery.new
|
4333
|
+
# dataset = bigquery.dataset "my_dataset"
|
4334
|
+
# table = dataset.create_table "my_table" do |schema|
|
4335
|
+
# schema.json "person", default_value_expression: "JSON '{"name": "Alice", "age": 30}'"
|
4336
|
+
# end
|
4337
|
+
#
|
4338
|
+
# @!group Schema
|
4339
|
+
def json name, description: nil, mode: :nullable, policy_tags: nil,
|
4340
|
+
default_value_expression: nil
|
4341
|
+
schema.json name, description: description, mode: mode, policy_tags: policy_tags,
|
4342
|
+
default_value_expression: default_value_expression
|
4343
|
+
end
|
4344
|
+
|
4287
4345
|
##
|
4288
4346
|
# Adds a record field to the schema. A block must be passed describing
|
4289
4347
|
# the nested fields of the record. For more information about nested
|
@@ -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 ||=
|
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,
|
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:
|
76
|
-
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.
|
4
|
+
version: 1.51.1
|
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:
|
12
|
+
date: 2024-12-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
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
|
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: '
|
27
|
+
version: '3.0'
|
76
28
|
- !ruby/object:Gem::Dependency
|
77
|
-
name:
|
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:
|
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: '
|
97
|
-
type: :
|
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: '
|
55
|
+
version: '0.71'
|
104
56
|
- !ruby/object:Gem::Dependency
|
105
|
-
name: google-
|
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: '
|
111
|
-
type: :
|
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: '
|
69
|
+
version: '0.13'
|
118
70
|
- !ruby/object:Gem::Dependency
|
119
|
-
name:
|
71
|
+
name: googleauth
|
120
72
|
requirement: !ruby/object:Gem::Requirement
|
121
73
|
requirements:
|
122
74
|
- - "~>"
|
123
75
|
- !ruby/object:Gem::Version
|
124
|
-
version: 1.
|
125
|
-
type: :
|
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.
|
83
|
+
version: '1.9'
|
132
84
|
- !ruby/object:Gem::Dependency
|
133
|
-
name:
|
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: '
|
139
|
-
type: :
|
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: '
|
97
|
+
version: '1.6'
|
146
98
|
- !ruby/object:Gem::Dependency
|
147
|
-
name:
|
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: :
|
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.
|
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.
|
192
|
+
rubygems_version: 3.5.23
|
325
193
|
signing_key:
|
326
194
|
specification_version: 4
|
327
195
|
summary: API Client library for Google BigQuery
|