google-cloud-bigquery 1.18.1 → 1.21.2

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.
@@ -113,12 +113,13 @@ module Google
113
113
  #
114
114
  # @param [Hash, Array<Hash>] rows A hash object or array of hash
115
115
  # objects containing the data.
116
- # @param [Array<String>] insert_ids A unique ID for each row. BigQuery
117
- # uses this property to detect duplicate insertion requests on a
118
- # best-effort basis. For more information, see [data
119
- # consistency](https://cloud.google.com/bigquery/streaming-data-into-bigquery#dataconsistency).
120
- # Optional. If not provided, the client library will assign a UUID
121
- # to each row before the request is sent.
116
+ # @param [Array<String|Symbol>, Symbol] insert_ids A unique ID for each row. BigQuery uses this property to
117
+ # detect duplicate insertion requests on a best-effort basis. For more information, see [data
118
+ # consistency](https://cloud.google.com/bigquery/streaming-data-into-bigquery#dataconsistency). Optional. If
119
+ # not provided, the client library will assign a UUID to each row before the request is sent.
120
+ #
121
+ # The value `:skip` can be provided to skip the generation of IDs for all rows, or to skip the generation of
122
+ # an ID for a specific row in the array.
122
123
  #
123
124
  def insert rows, insert_ids: nil
124
125
  return nil if rows.nil?
@@ -224,10 +225,14 @@ module Google
224
225
 
225
226
  def validate_insert_args rows, insert_ids
226
227
  rows = [rows] if rows.is_a? Hash
228
+ raise ArgumentError, "No rows provided" if rows.empty?
229
+
230
+ insert_ids = Array.new(rows.count) { :skip } if insert_ids == :skip
227
231
  insert_ids = Array insert_ids
228
232
  if insert_ids.count.positive? && insert_ids.count != rows.count
229
233
  raise ArgumentError, "insert_ids must be the same size as rows"
230
234
  end
235
+
231
236
  [rows, insert_ids]
232
237
  end
233
238
 
@@ -332,8 +337,13 @@ module Google
332
337
  end
333
338
 
334
339
  def addl_bytes_for json_row, insert_id
335
- # "{\"insertId\":\"\",\"json\":},".bytesize #=> 24
336
- 24 + json_row.to_json.bytesize + insert_id.bytesize
340
+ if insert_id == :skip
341
+ # "{\"json\":},".bytesize #=> 10
342
+ 10 + json_row.to_json.bytesize
343
+ else
344
+ # "{\"insertId\":\"\",\"json\":},".bytesize #=> 24
345
+ 24 + json_row.to_json.bytesize + insert_id.bytesize
346
+ end
337
347
  end
338
348
  end
339
349
 
@@ -78,8 +78,7 @@ module Google
78
78
  def next
79
79
  return nil unless next?
80
80
  ensure_service!
81
- options = { token: token, max: @max }
82
- gapi = @service.list_tables @dataset_id, options
81
+ gapi = @service.list_tables @dataset_id, token: token, max: @max
83
82
  self.class.from_gapi gapi, @service, @dataset_id, @max
84
83
  end
85
84
 
@@ -34,9 +34,12 @@ module Google
34
34
  # "WHERE time_of_date = @time",
35
35
  # params: { time: fourpm }
36
36
  #
37
+ # # Iterate over the first page of results
37
38
  # data.each do |row|
38
39
  # puts row[:name]
39
40
  # end
41
+ # # Retrieve the next page of results
42
+ # data = data.next if data.next?
40
43
  #
41
44
  # @example Create Time with fractional seconds:
42
45
  # require "google/cloud/bigquery"
@@ -49,9 +52,12 @@ module Google
49
52
  # "WHERE time_of_date >= @time",
50
53
  # params: { time: precise_time }
51
54
  #
55
+ # # Iterate over the first page of results
52
56
  # data.each do |row|
53
57
  # puts row[:name]
54
58
  # end
59
+ # # Retrieve the next page of results
60
+ # data = data.next if data.next?
55
61
  #
56
62
  Time = Struct.new :value
57
63
  end
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Bigquery
19
- VERSION = "1.18.1".freeze
19
+ VERSION = "1.21.2".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.18.1
4
+ version: 1.21.2
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: 2019-12-20 00:00:00.000000000 Z
12
+ date: 2020-07-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: concurrent-ruby
@@ -115,14 +115,14 @@ dependencies:
115
115
  requirements:
116
116
  - - "~>"
117
117
  - !ruby/object:Gem::Version
118
- version: '5.10'
118
+ version: '5.14'
119
119
  type: :development
120
120
  prerelease: false
121
121
  version_requirements: !ruby/object:Gem::Requirement
122
122
  requirements:
123
123
  - - "~>"
124
124
  - !ruby/object:Gem::Version
125
- version: '5.10'
125
+ version: '5.14'
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: minitest-autotest
128
128
  requirement: !ruby/object:Gem::Requirement
@@ -185,14 +185,14 @@ dependencies:
185
185
  requirements:
186
186
  - - "~>"
187
187
  - !ruby/object:Gem::Version
188
- version: '0.9'
188
+ version: '0.18'
189
189
  type: :development
190
190
  prerelease: false
191
191
  version_requirements: !ruby/object:Gem::Requirement
192
192
  requirements:
193
193
  - - "~>"
194
194
  - !ruby/object:Gem::Version
195
- version: '0.9'
195
+ version: '0.18'
196
196
  - !ruby/object:Gem::Dependency
197
197
  name: yard
198
198
  requirement: !ruby/object:Gem::Requirement
@@ -240,6 +240,7 @@ files:
240
240
  - TROUBLESHOOTING.md
241
241
  - lib/google-cloud-bigquery.rb
242
242
  - lib/google/cloud/bigquery.rb
243
+ - lib/google/cloud/bigquery/argument.rb
243
244
  - lib/google/cloud/bigquery/convert.rb
244
245
  - lib/google/cloud/bigquery/copy_job.rb
245
246
  - lib/google/cloud/bigquery/credentials.rb
@@ -259,6 +260,8 @@ files:
259
260
  - lib/google/cloud/bigquery/project.rb
260
261
  - lib/google/cloud/bigquery/project/list.rb
261
262
  - lib/google/cloud/bigquery/query_job.rb
263
+ - lib/google/cloud/bigquery/routine.rb
264
+ - lib/google/cloud/bigquery/routine/list.rb
262
265
  - lib/google/cloud/bigquery/schema.rb
263
266
  - lib/google/cloud/bigquery/schema/field.rb
264
267
  - lib/google/cloud/bigquery/service.rb
@@ -287,7 +290,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
287
290
  - !ruby/object:Gem::Version
288
291
  version: '0'
289
292
  requirements: []
290
- rubygems_version: 3.0.6
293
+ rubygems_version: 3.1.3
291
294
  signing_key:
292
295
  specification_version: 4
293
296
  summary: API Client library for Google BigQuery