google-cloud-bigquery 1.25.0 → 1.30.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 +55 -0
- data/CONTRIBUTING.md +4 -5
- data/LOGGING.md +1 -1
- data/OVERVIEW.md +15 -14
- data/lib/google/cloud/bigquery/convert.rb +72 -76
- data/lib/google/cloud/bigquery/copy_job.rb +1 -0
- data/lib/google/cloud/bigquery/data.rb +2 -2
- data/lib/google/cloud/bigquery/dataset.rb +181 -62
- data/lib/google/cloud/bigquery/dataset/access.rb +3 -3
- data/lib/google/cloud/bigquery/dataset/list.rb +2 -2
- data/lib/google/cloud/bigquery/external.rb +328 -3
- data/lib/google/cloud/bigquery/extract_job.rb +8 -10
- data/lib/google/cloud/bigquery/job.rb +43 -3
- data/lib/google/cloud/bigquery/job/list.rb +4 -4
- data/lib/google/cloud/bigquery/load_job.rb +228 -27
- data/lib/google/cloud/bigquery/model/list.rb +2 -2
- data/lib/google/cloud/bigquery/policy.rb +2 -1
- data/lib/google/cloud/bigquery/project.rb +47 -43
- data/lib/google/cloud/bigquery/project/list.rb +2 -2
- data/lib/google/cloud/bigquery/query_job.rb +62 -48
- data/lib/google/cloud/bigquery/routine.rb +128 -9
- data/lib/google/cloud/bigquery/routine/list.rb +2 -2
- data/lib/google/cloud/bigquery/schema.rb +39 -3
- data/lib/google/cloud/bigquery/schema/field.rb +63 -13
- data/lib/google/cloud/bigquery/service.rb +11 -13
- data/lib/google/cloud/bigquery/standard_sql.rb +15 -3
- data/lib/google/cloud/bigquery/table.rb +246 -52
- data/lib/google/cloud/bigquery/table/async_inserter.rb +44 -17
- data/lib/google/cloud/bigquery/table/list.rb +2 -2
- data/lib/google/cloud/bigquery/version.rb +1 -1
- metadata +15 -15
@@ -64,7 +64,10 @@ module Google
|
|
64
64
|
class AsyncInserter
|
65
65
|
include MonitorMixin
|
66
66
|
|
67
|
-
attr_reader :max_bytes
|
67
|
+
attr_reader :max_bytes
|
68
|
+
attr_reader :max_rows
|
69
|
+
attr_reader :interval
|
70
|
+
attr_reader :threads
|
68
71
|
##
|
69
72
|
# @private Implementation accessors
|
70
73
|
attr_reader :table, :batch
|
@@ -98,6 +101,21 @@ module Google
|
|
98
101
|
# collected in batches and inserted together.
|
99
102
|
# See {Google::Cloud::Bigquery::Table#insert_async}.
|
100
103
|
#
|
104
|
+
# Simple Ruby types are generally accepted per JSON rules, along with the following support for BigQuery's
|
105
|
+
# more complex types:
|
106
|
+
#
|
107
|
+
# | BigQuery | Ruby | Notes |
|
108
|
+
# |--------------|--------------------------------------|----------------------------------------------------|
|
109
|
+
# | `NUMERIC` | `BigDecimal` | `BigDecimal` values will be rounded to scale 9. |
|
110
|
+
# | `BIGNUMERIC` | `String` | Pass as `String` to avoid rounding to scale 9. |
|
111
|
+
# | `DATETIME` | `DateTime` | `DATETIME` does not support time zone. |
|
112
|
+
# | `DATE` | `Date` | |
|
113
|
+
# | `TIMESTAMP` | `Time` | |
|
114
|
+
# | `TIME` | `Google::Cloud::BigQuery::Time` | |
|
115
|
+
# | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
|
116
|
+
# | `ARRAY` | `Array` | Nested arrays, `nil` values are not supported. |
|
117
|
+
# | `STRUCT` | `Hash` | Hash keys may be strings or symbols. |
|
118
|
+
#
|
101
119
|
# Because BigQuery's streaming API is designed for high insertion
|
102
120
|
# rates, modifications to the underlying table metadata are eventually
|
103
121
|
# consistent when interacting with the streaming system. In most cases
|
@@ -111,8 +129,11 @@ module Google
|
|
111
129
|
# @see https://cloud.google.com/bigquery/troubleshooting-errors#metadata-errors-for-streaming-inserts
|
112
130
|
# BigQuery Troubleshooting: Metadata errors for streaming inserts
|
113
131
|
#
|
114
|
-
# @param [Hash, Array<Hash>] rows A hash object or array of hash
|
115
|
-
#
|
132
|
+
# @param [Hash, Array<Hash>] rows A hash object or array of hash objects
|
133
|
+
# containing the data. Required. `BigDecimal` values will be rounded to
|
134
|
+
# scale 9 to conform with the BigQuery `NUMERIC` data type. To avoid
|
135
|
+
# rounding `BIGNUMERIC` type values with scale greater than 9, use `String`
|
136
|
+
# instead of `BigDecimal`.
|
116
137
|
# @param [Array<String|Symbol>, Symbol] insert_ids A unique ID for each row. BigQuery uses this property to
|
117
138
|
# detect duplicate insertion requests on a best-effort basis. For more information, see [data
|
118
139
|
# consistency](https://cloud.google.com/bigquery/streaming-data-into-bigquery#dataconsistency). Optional. If
|
@@ -265,18 +286,19 @@ module Google
|
|
265
286
|
json_rows = @batch.json_rows
|
266
287
|
insert_ids = @batch.insert_ids
|
267
288
|
Concurrent::Future.new executor: @thread_pool do
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
289
|
+
raise ArgumentError, "No rows provided" if json_rows.empty?
|
290
|
+
insert_resp = @table.service.insert_tabledata_json_rows @table.dataset_id,
|
291
|
+
@table.table_id,
|
292
|
+
json_rows,
|
293
|
+
skip_invalid: @skip_invalid,
|
294
|
+
ignore_unknown: @ignore_unknown,
|
295
|
+
insert_ids: insert_ids
|
296
|
+
|
297
|
+
result = Result.new InsertResponse.from_gapi(orig_rows, insert_resp)
|
298
|
+
rescue StandardError => e
|
299
|
+
result = Result.new nil, e
|
300
|
+
ensure
|
301
|
+
@callback&.call result
|
280
302
|
end.execute
|
281
303
|
|
282
304
|
@batch = nil
|
@@ -286,7 +308,11 @@ module Google
|
|
286
308
|
##
|
287
309
|
# @private
|
288
310
|
class Batch
|
289
|
-
attr_reader :max_bytes
|
311
|
+
attr_reader :max_bytes
|
312
|
+
attr_reader :max_rows
|
313
|
+
attr_reader :rows
|
314
|
+
attr_reader :json_rows
|
315
|
+
attr_reader :insert_ids
|
290
316
|
|
291
317
|
def initialize max_bytes: 10_000_000, max_rows: 500
|
292
318
|
@max_bytes = max_bytes
|
@@ -395,7 +421,8 @@ module Google
|
|
395
421
|
@error = error
|
396
422
|
end
|
397
423
|
|
398
|
-
attr_reader :insert_response
|
424
|
+
attr_reader :insert_response
|
425
|
+
attr_reader :error
|
399
426
|
|
400
427
|
##
|
401
428
|
# Checks if an error is present, meaning that the insert operation
|
@@ -130,12 +130,12 @@ module Google
|
|
130
130
|
# puts table.name
|
131
131
|
# end
|
132
132
|
#
|
133
|
-
def all request_limit: nil
|
133
|
+
def all request_limit: nil, &block
|
134
134
|
request_limit = request_limit.to_i if request_limit
|
135
135
|
return enum_for :all, request_limit: request_limit unless block_given?
|
136
136
|
results = self
|
137
137
|
loop do
|
138
|
-
results.each
|
138
|
+
results.each(&block)
|
139
139
|
if request_limit
|
140
140
|
request_limit -= 1
|
141
141
|
break if request_limit.negative?
|
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.30.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Moore
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-04-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: concurrent-ruby
|
@@ -26,47 +26,47 @@ dependencies:
|
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '1.0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
|
-
name: google-
|
29
|
+
name: google-apis-bigquery_v2
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '0.
|
34
|
+
version: '0.1'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '0.
|
41
|
+
version: '0.1'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
|
-
name:
|
43
|
+
name: googleauth
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
48
|
+
version: '0.9'
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: '
|
55
|
+
version: '0.9'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
|
-
name:
|
57
|
+
name: google-cloud-core
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
60
|
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: '
|
62
|
+
version: '1.2'
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: '
|
69
|
+
version: '1.2'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: mini_mime
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
@@ -101,14 +101,14 @@ dependencies:
|
|
101
101
|
requirements:
|
102
102
|
- - "~>"
|
103
103
|
- !ruby/object:Gem::Version
|
104
|
-
version: 1.
|
104
|
+
version: 1.25.1
|
105
105
|
type: :development
|
106
106
|
prerelease: false
|
107
107
|
version_requirements: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
109
|
- - "~>"
|
110
110
|
- !ruby/object:Gem::Version
|
111
|
-
version: 1.
|
111
|
+
version: 1.25.1
|
112
112
|
- !ruby/object:Gem::Dependency
|
113
113
|
name: minitest
|
114
114
|
requirement: !ruby/object:Gem::Requirement
|
@@ -284,14 +284,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
284
284
|
requirements:
|
285
285
|
- - ">="
|
286
286
|
- !ruby/object:Gem::Version
|
287
|
-
version: '2.
|
287
|
+
version: '2.5'
|
288
288
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
289
289
|
requirements:
|
290
290
|
- - ">="
|
291
291
|
- !ruby/object:Gem::Version
|
292
292
|
version: '0'
|
293
293
|
requirements: []
|
294
|
-
rubygems_version: 3.
|
294
|
+
rubygems_version: 3.2.13
|
295
295
|
signing_key:
|
296
296
|
specification_version: 4
|
297
297
|
summary: API Client library for Google BigQuery
|