google-cloud-bigquery 1.42.0 → 1.49.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +72 -0
- data/lib/google/cloud/bigquery/convert.rb +2 -3
- data/lib/google/cloud/bigquery/dataset.rb +78 -13
- data/lib/google/cloud/bigquery/load_job.rb +495 -26
- data/lib/google/cloud/bigquery/project.rb +373 -1
- data/lib/google/cloud/bigquery/query_job.rb +6 -4
- data/lib/google/cloud/bigquery/schema/field.rb +83 -0
- data/lib/google/cloud/bigquery/schema.rb +351 -44
- data/lib/google/cloud/bigquery/service.rb +25 -5
- data/lib/google/cloud/bigquery/table/async_inserter.rb +1 -0
- data/lib/google/cloud/bigquery/table.rb +458 -32
- data/lib/google/cloud/bigquery/version.rb +1 -1
- data/lib/google/cloud/bigquery.rb +5 -3
- data/lib/google-cloud-bigquery.rb +9 -3
- metadata +18 -164
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ade2c82829a9b7d91e10ed3e475e940d03c33d01f09c8322bf9412fb5beb96db
|
4
|
+
data.tar.gz: d6379bc028117ffa5c16ab4fd4936f55e78f66e6d8550a222426d13ef472a2dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7df1b27b3d0e4fd7a4de8de68911b9748c8b80c28bc8e1cc067357e3798d5905c70c44b36cfa9075b37935e90648cd8f5ac57437f299ae1f0cdd0de51bd39fb9
|
7
|
+
data.tar.gz: 6331414d5f3b02f69c9649454e13fd078fd95420c48f54623196325f050b6c6f4bb4d7df9c799bd63839db0a11fbc9d2bcebf0a227d33bf935e7ff10861d90dd
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,77 @@
|
|
1
1
|
# Release History
|
2
2
|
|
3
|
+
### 1.49.0 (2024-03-10)
|
4
|
+
|
5
|
+
#### Features
|
6
|
+
|
7
|
+
* Update minimum supported Ruby version to 2.7 ([#25298](https://github.com/googleapis/google-cloud-ruby/issues/25298))
|
8
|
+
|
9
|
+
### 1.48.1 (2024-02-10)
|
10
|
+
|
11
|
+
#### Documentation
|
12
|
+
|
13
|
+
* Correct an example snippet related to storage_billing_model ([#24796](https://github.com/googleapis/google-cloud-ruby/issues/24796))
|
14
|
+
|
15
|
+
### 1.48.0 (2024-02-08)
|
16
|
+
|
17
|
+
#### Features
|
18
|
+
|
19
|
+
* Support accessing storage_ billing_model field in a dataset ([#24755](https://github.com/googleapis/google-cloud-ruby/issues/24755))
|
20
|
+
|
21
|
+
### 1.47.0 (2024-02-05)
|
22
|
+
|
23
|
+
#### Features
|
24
|
+
|
25
|
+
* add json type support ([#24491](https://github.com/googleapis/google-cloud-ruby/issues/24491))
|
26
|
+
|
27
|
+
### 1.46.1 (2024-01-26)
|
28
|
+
|
29
|
+
#### Bug Fixes
|
30
|
+
|
31
|
+
* Raise an error on mismatching universe domain ([#24485](https://github.com/googleapis/google-cloud-ruby/issues/24485))
|
32
|
+
|
33
|
+
### 1.46.0 (2024-01-25)
|
34
|
+
|
35
|
+
#### Features
|
36
|
+
|
37
|
+
* Support for universe_domain ([#24448](https://github.com/googleapis/google-cloud-ruby/issues/24448))
|
38
|
+
|
39
|
+
### 1.45.0 (2023-09-25)
|
40
|
+
|
41
|
+
#### Features
|
42
|
+
|
43
|
+
* support load job with session ([#23320](https://github.com/googleapis/google-cloud-ruby/issues/23320))
|
44
|
+
|
45
|
+
### 1.44.2 (2023-09-12)
|
46
|
+
|
47
|
+
#### Bug Fixes
|
48
|
+
|
49
|
+
* Avoid dataset reload when accessing location ([#22905](https://github.com/googleapis/google-cloud-ruby/issues/22905))
|
50
|
+
|
51
|
+
### 1.44.1 (2023-09-08)
|
52
|
+
|
53
|
+
#### Bug Fixes
|
54
|
+
|
55
|
+
* remove unnecessary warning ([#22904](https://github.com/googleapis/google-cloud-ruby/issues/22904))
|
56
|
+
|
57
|
+
### 1.44.0 (2023-09-04)
|
58
|
+
|
59
|
+
#### Features
|
60
|
+
|
61
|
+
* support BIGQUERY_EMULATOR_HOST env variable for endpoint
|
62
|
+
|
63
|
+
### 1.43.1 (2023-05-19)
|
64
|
+
|
65
|
+
#### Bug Fixes
|
66
|
+
|
67
|
+
* ensure schema for data parsing ([#21616](https://github.com/googleapis/google-cloud-ruby/issues/21616))
|
68
|
+
|
69
|
+
### 1.43.0 (2023-05-10)
|
70
|
+
|
71
|
+
#### Features
|
72
|
+
|
73
|
+
* Added support for default value expression ([#21540](https://github.com/googleapis/google-cloud-ruby/issues/21540))
|
74
|
+
|
3
75
|
### 1.42.0 (2023-01-15)
|
4
76
|
|
5
77
|
#### 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
|
@@ -269,7 +269,6 @@ module Google
|
|
269
269
|
#
|
270
270
|
def location
|
271
271
|
return nil if reference?
|
272
|
-
ensure_full_data!
|
273
272
|
@gapi.location
|
274
273
|
end
|
275
274
|
|
@@ -413,6 +412,56 @@ module Google
|
|
413
412
|
patch_gapi! :default_encryption_configuration
|
414
413
|
end
|
415
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
|
+
|
416
465
|
##
|
417
466
|
# Retrieves the access rules for a Dataset. The rules can be updated
|
418
467
|
# when passing a block, see {Dataset::Access} for all the methods
|
@@ -479,7 +528,7 @@ module Google
|
|
479
528
|
def tags
|
480
529
|
ensure_full_data!
|
481
530
|
return nil if @gapi.tags.nil?
|
482
|
-
@gapi.tags.map { |gapi| Tag.from_gapi
|
531
|
+
@gapi.tags.map { |gapi| Tag.from_gapi gapi }
|
483
532
|
end
|
484
533
|
|
485
534
|
##
|
@@ -720,7 +769,7 @@ module Google
|
|
720
769
|
use_legacy_sql: use_legacy_sql,
|
721
770
|
user_defined_function_resources: udfs_gapi(udfs)
|
722
771
|
)
|
723
|
-
}.
|
772
|
+
}.compact
|
724
773
|
new_view = Google::Apis::BigqueryV2::Table.new(**new_view_opts)
|
725
774
|
|
726
775
|
gapi = service.insert_table dataset_id, new_view
|
@@ -794,7 +843,7 @@ module Google
|
|
794
843
|
query: query,
|
795
844
|
refresh_interval_ms: refresh_interval_ms
|
796
845
|
)
|
797
|
-
}.
|
846
|
+
}.compact
|
798
847
|
new_view = Google::Apis::BigqueryV2::Table.new(**new_view_opts)
|
799
848
|
|
800
849
|
gapi = service.insert_table dataset_id, new_view
|
@@ -1181,6 +1230,7 @@ module Google
|
|
1181
1230
|
# | `DATETIME` | `DateTime` | `DATETIME` does not support time zone. |
|
1182
1231
|
# | `DATE` | `Date` | |
|
1183
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. |
|
1184
1234
|
# | `TIMESTAMP` | `Time` | |
|
1185
1235
|
# | `TIME` | `Google::Cloud::BigQuery::Time` | |
|
1186
1236
|
# | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
|
@@ -1207,6 +1257,7 @@ module Google
|
|
1207
1257
|
# * `:DATETIME`
|
1208
1258
|
# * `:DATE`
|
1209
1259
|
# * `:GEOGRAPHY`
|
1260
|
+
# * `:JSON`
|
1210
1261
|
# * `:TIMESTAMP`
|
1211
1262
|
# * `:TIME`
|
1212
1263
|
# * `:BYTES`
|
@@ -1586,6 +1637,7 @@ module Google
|
|
1586
1637
|
# | `DATETIME` | `DateTime` | `DATETIME` does not support time zone. |
|
1587
1638
|
# | `DATE` | `Date` | |
|
1588
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. |
|
1589
1641
|
# | `TIMESTAMP` | `Time` | |
|
1590
1642
|
# | `TIME` | `Google::Cloud::BigQuery::Time` | |
|
1591
1643
|
# | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
|
@@ -1612,6 +1664,7 @@ module Google
|
|
1612
1664
|
# * `:DATETIME`
|
1613
1665
|
# * `:DATE`
|
1614
1666
|
# * `:GEOGRAPHY`
|
1667
|
+
# * `:JSON`
|
1615
1668
|
# * `:TIMESTAMP`
|
1616
1669
|
# * `:TIME`
|
1617
1670
|
# * `:BYTES`
|
@@ -2031,15 +2084,20 @@ module Google
|
|
2031
2084
|
# * The key portion of a label must be unique. However, you can use the
|
2032
2085
|
# same key with multiple resources.
|
2033
2086
|
# * Keys must start with a lowercase letter or international character.
|
2087
|
+
# @param [Boolean] dryrun If set, don't actually run this job. Behavior
|
2088
|
+
# is undefined however for non-query jobs and may result in an error.
|
2089
|
+
# Deprecated.
|
2090
|
+
# @param [Boolean] create_session If set to true a new session will be created
|
2091
|
+
# and the load job will happen in the table created within that session.
|
2092
|
+
# Note: This will work only for _SESSION dataset.
|
2093
|
+
# @param [string] session_id Session ID in which the load job must run.
|
2094
|
+
#
|
2034
2095
|
# @yield [updater] A block for setting the schema and other
|
2035
2096
|
# options for the destination table. The schema can be omitted if the
|
2036
2097
|
# destination table already exists, or if you're loading data from a
|
2037
2098
|
# Google Cloud Datastore backup.
|
2038
2099
|
# @yieldparam [Google::Cloud::Bigquery::LoadJob::Updater] updater An
|
2039
2100
|
# updater to modify the load job and its schema.
|
2040
|
-
# @param [Boolean] dryrun If set, don't actually run this job. Behavior
|
2041
|
-
# is undefined however for non-query jobs and may result in an error.
|
2042
|
-
# Deprecated.
|
2043
2101
|
#
|
2044
2102
|
# @return [Google::Cloud::Bigquery::LoadJob] A new load job object.
|
2045
2103
|
#
|
@@ -2127,7 +2185,7 @@ module Google
|
|
2127
2185
|
def load_job table_id, files, format: nil, create: nil, write: nil, projection_fields: nil, jagged_rows: nil,
|
2128
2186
|
quoted_newlines: nil, encoding: nil, delimiter: nil, ignore_unknown: nil, max_bad_records: nil,
|
2129
2187
|
quote: nil, skip_leading: nil, schema: nil, job_id: nil, prefix: nil, labels: nil, autodetect: nil,
|
2130
|
-
null_marker: nil, dryrun: nil
|
2188
|
+
null_marker: nil, dryrun: nil, create_session: nil, session_id: nil
|
2131
2189
|
ensure_service!
|
2132
2190
|
|
2133
2191
|
updater = load_job_updater table_id,
|
@@ -2136,7 +2194,8 @@ module Google
|
|
2136
2194
|
delimiter: delimiter, ignore_unknown: ignore_unknown,
|
2137
2195
|
max_bad_records: max_bad_records, quote: quote, skip_leading: skip_leading,
|
2138
2196
|
dryrun: dryrun, schema: schema, job_id: job_id, prefix: prefix, labels: labels,
|
2139
|
-
autodetect: autodetect, null_marker: null_marker
|
2197
|
+
autodetect: autodetect, null_marker: null_marker, create_session: create_session,
|
2198
|
+
session_id: session_id
|
2140
2199
|
|
2141
2200
|
yield updater if block_given?
|
2142
2201
|
|
@@ -2262,6 +2321,8 @@ module Google
|
|
2262
2321
|
# See {Project#schema} for the creation of the schema for use with
|
2263
2322
|
# this option. Also note that for most use cases, the block yielded by
|
2264
2323
|
# this method is a more convenient way to configure the schema.
|
2324
|
+
# @param [string] session_id Session ID in which the load job must run.
|
2325
|
+
#
|
2265
2326
|
#
|
2266
2327
|
# @yield [updater] A block for setting the schema of the destination
|
2267
2328
|
# table and other options for the load job. The schema can be omitted
|
@@ -2354,13 +2415,13 @@ module Google
|
|
2354
2415
|
#
|
2355
2416
|
def load table_id, files, format: nil, create: nil, write: nil, projection_fields: nil, jagged_rows: nil,
|
2356
2417
|
quoted_newlines: nil, encoding: nil, delimiter: nil, ignore_unknown: nil, max_bad_records: nil,
|
2357
|
-
quote: nil, skip_leading: nil, schema: nil, autodetect: nil, null_marker: nil, &block
|
2418
|
+
quote: nil, skip_leading: nil, schema: nil, autodetect: nil, null_marker: nil, session_id: nil, &block
|
2358
2419
|
job = load_job table_id, files,
|
2359
2420
|
format: format, create: create, write: write, projection_fields: projection_fields,
|
2360
2421
|
jagged_rows: jagged_rows, quoted_newlines: quoted_newlines, encoding: encoding,
|
2361
2422
|
delimiter: delimiter, ignore_unknown: ignore_unknown, max_bad_records: max_bad_records,
|
2362
2423
|
quote: quote, skip_leading: skip_leading, schema: schema, autodetect: autodetect,
|
2363
|
-
null_marker: null_marker, &block
|
2424
|
+
null_marker: null_marker, session_id: session_id, &block
|
2364
2425
|
|
2365
2426
|
job.wait_until_done!
|
2366
2427
|
ensure_job_succeeded! job
|
@@ -2546,6 +2607,7 @@ module Google
|
|
2546
2607
|
# | `DATETIME` | `DateTime` | `DATETIME` does not support time zone. |
|
2547
2608
|
# | `DATE` | `Date` | |
|
2548
2609
|
# | `GEOGRAPHY` | `String` | |
|
2610
|
+
# | `JSON` | `String` (Stringified JSON) | String, as JSON does not have a schema to verify. |
|
2549
2611
|
# | `TIMESTAMP` | `Time` | |
|
2550
2612
|
# | `TIME` | `Google::Cloud::BigQuery::Time` | |
|
2551
2613
|
# | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
|
@@ -2776,7 +2838,7 @@ module Google
|
|
2776
2838
|
params = {
|
2777
2839
|
dataset: dataset_ref,
|
2778
2840
|
target_types: target_types
|
2779
|
-
}.
|
2841
|
+
}.compact
|
2780
2842
|
Google::Apis::BigqueryV2::DatasetAccessEntry.new(**params)
|
2781
2843
|
end
|
2782
2844
|
|
@@ -2904,7 +2966,8 @@ module Google
|
|
2904
2966
|
def load_job_updater table_id, format: nil, create: nil, write: nil, projection_fields: nil, jagged_rows: nil,
|
2905
2967
|
quoted_newlines: nil, encoding: nil, delimiter: nil, ignore_unknown: nil,
|
2906
2968
|
max_bad_records: nil, quote: nil, skip_leading: nil, dryrun: nil, schema: nil, job_id: nil,
|
2907
|
-
prefix: nil, labels: nil, autodetect: nil, null_marker: nil
|
2969
|
+
prefix: nil, labels: nil, autodetect: nil, null_marker: nil, create_session: nil,
|
2970
|
+
session_id: nil
|
2908
2971
|
new_job = load_job_gapi table_id, dryrun, job_id: job_id, prefix: prefix
|
2909
2972
|
LoadJob::Updater.new(new_job).tap do |job|
|
2910
2973
|
job.location = location if location # may be dataset reference
|
@@ -2913,6 +2976,8 @@ module Google
|
|
2913
2976
|
job.schema = schema unless schema.nil?
|
2914
2977
|
job.autodetect = autodetect unless autodetect.nil?
|
2915
2978
|
job.labels = labels unless labels.nil?
|
2979
|
+
job.create_session = create_session unless create_session.nil?
|
2980
|
+
job.session_id = session_id unless session_id.nil?
|
2916
2981
|
load_job_file_options! job, format: format,
|
2917
2982
|
projection_fields: projection_fields,
|
2918
2983
|
jagged_rows: jagged_rows,
|