google-cloud-bigquery 1.25.0 → 1.30.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.
@@ -64,7 +64,10 @@ module Google
64
64
  class AsyncInserter
65
65
  include MonitorMixin
66
66
 
67
- attr_reader :max_bytes, :max_rows, :interval, :threads
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
- # objects containing the data.
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
- begin
269
- raise ArgumentError, "No rows provided" if json_rows.empty?
270
- options = { skip_invalid: @skip_invalid, ignore_unknown: @ignore_unknown, insert_ids: insert_ids }
271
- insert_resp = @table.service.insert_tabledata_json_rows(
272
- @table.dataset_id, @table.table_id, json_rows, options
273
- )
274
- result = Result.new InsertResponse.from_gapi(orig_rows, insert_resp)
275
- rescue StandardError => e
276
- result = Result.new nil, e
277
- ensure
278
- @callback&.call result
279
- end
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, :max_rows, :rows, :json_rows, :insert_ids
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, :error
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 { |r| yield r }
138
+ results.each(&block)
139
139
  if request_limit
140
140
  request_limit -= 1
141
141
  break if request_limit.negative?
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Bigquery
19
- VERSION = "1.25.0".freeze
19
+ VERSION = "1.30.0".freeze
20
20
  end
21
21
  end
22
22
  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.25.0
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: 2020-11-16 00:00:00.000000000 Z
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-api-client
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.47'
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.47'
41
+ version: '0.1'
42
42
  - !ruby/object:Gem::Dependency
43
- name: google-cloud-core
43
+ name: googleauth
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '1.2'
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: '1.2'
55
+ version: '0.9'
56
56
  - !ruby/object:Gem::Dependency
57
- name: googleauth
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: '0.9'
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: '0.9'
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.24.0
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.24.0
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.4'
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.1.4
294
+ rubygems_version: 3.2.13
295
295
  signing_key:
296
296
  specification_version: 4
297
297
  summary: API Client library for Google BigQuery