google-cloud-bigquery 1.14.1 → 1.15.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5fd3861cb3bf54760f6b0d3a46858c98874189855f86a41caaa2c791c713c5e8
4
- data.tar.gz: 14b582d242c0482e8d1466d73fe32339e1f6e35e1a9df690ae0196b80b9f32d6
3
+ metadata.gz: 4df9efe3b6ac3249b82a3745877dd0aab98407b753ca178f37c9e321f3d30751
4
+ data.tar.gz: 51e19ccf8ade5f37117eec63548fbefc72fb84c2537a62d6ffd539c2f4ad4360
5
5
  SHA512:
6
- metadata.gz: f58f559418c9be2386ce0802f133615d36293734ed96450b4041c85645960cd196deb69bf25d02852a8147a89c334ead418ba8778007c546c86978b7577ffcbc
7
- data.tar.gz: b4a814a2b5307dec611dd9af3628511989d9c5cdbb8873205440f1b8685543bfa4a972be5822a08bc538eb8e6c4bc58bca2094f67a8ee95837f011a21bc84cf6
6
+ metadata.gz: 19d1d3d6e81228fb7c52939a72079c4016dbdf41826a79b2b010d0115bd1002b9931865d178a777a8139092fc5a147ab2046262bac2031ec2ea1de181344bca2
7
+ data.tar.gz: 2061b50a1e721dd602b0a689294c326ab2e12fe379c1081b3b2de6305a8b83122d3c8065c4b3c6df725b0a0c65395d1f92a12df659ee24a4205047a0278ac08c
@@ -1,5 +1,19 @@
1
1
  # Release History
2
2
 
3
+ ### 1.15.0 / 2019-09-30
4
+
5
+ #### Features
6
+
7
+ * Add Model encryption
8
+ * Add Model#encryption
9
+ * Add Model#encryption=
10
+ * Add range support for Google Sheets
11
+ * Add External::SheetsSource#range
12
+ * Add External::SheetsSource#range=
13
+ * Support use_avro_logical_types on extract jobs
14
+ * Add ExtractJob#use_avro_logical_types?
15
+ * Add ExtractJob::Updater#use_avro_logical_types=
16
+
3
17
  ### 1.14.1 / 2019-09-04
4
18
 
5
19
  #### Documentation
@@ -1224,6 +1224,52 @@ module Google
1224
1224
  frozen_check!
1225
1225
  @gapi.google_sheets_options.skip_leading_rows = row_count
1226
1226
  end
1227
+
1228
+ ##
1229
+ # Range of a sheet to query from. Only used when non-empty. Typical
1230
+ # format: `{sheet_name}!{top_left_cell_id}:{bottom_right_cell_id}`.
1231
+ #
1232
+ # @return [String] Range of a sheet to query from.
1233
+ #
1234
+ # @example
1235
+ # require "google/cloud/bigquery"
1236
+ #
1237
+ # bigquery = Google::Cloud::Bigquery.new
1238
+ #
1239
+ # sheets_url = "https://docs.google.com/spreadsheets/d/1234567980"
1240
+ # sheets_table = bigquery.external sheets_url do |sheets|
1241
+ # sheets.range = "sheet1!A1:B20"
1242
+ # end
1243
+ #
1244
+ # sheets_table.range #=> "sheet1!A1:B20"
1245
+ #
1246
+ def range
1247
+ @gapi.google_sheets_options.range
1248
+ end
1249
+
1250
+ ##
1251
+ # Set the range of a sheet to query from. Only used when non-empty.
1252
+ # Typical format:
1253
+ # `{sheet_name}!{top_left_cell_id}:{bottom_right_cell_id}`.
1254
+ #
1255
+ # @param [String] new_range New range of a sheet to query from.
1256
+ #
1257
+ # @example
1258
+ # require "google/cloud/bigquery"
1259
+ #
1260
+ # bigquery = Google::Cloud::Bigquery.new
1261
+ #
1262
+ # sheets_url = "https://docs.google.com/spreadsheets/d/1234567980"
1263
+ # sheets_table = bigquery.external sheets_url do |sheets|
1264
+ # sheets.range = "sheet1!A1:B20"
1265
+ # end
1266
+ #
1267
+ # sheets_table.range #=> "sheet1!A1:B20"
1268
+ #
1269
+ def range= new_range
1270
+ frozen_check!
1271
+ @gapi.google_sheets_options.range = new_range
1272
+ end
1227
1273
  end
1228
1274
 
1229
1275
  ##
@@ -156,6 +156,20 @@ module Google
156
156
  Hash[destinations.zip destinations_file_counts]
157
157
  end
158
158
 
159
+ ##
160
+ # If `#avro?` (`#format` is set to `"AVRO"`), this flag indicates
161
+ # whether to enable extracting applicable column types (such as
162
+ # `TIMESTAMP`) to their corresponding AVRO logical types
163
+ # (`timestamp-micros`), instead of only using their raw types
164
+ # (`avro-long`).
165
+ #
166
+ # @return [Boolean] `true` when applicable column types will use their
167
+ # corresponding AVRO logical types, `false` otherwise.
168
+ #
169
+ def use_avro_logical_types?
170
+ @gapi.configuration.extract.use_avro_logical_types
171
+ end
172
+
159
173
  ##
160
174
  # Yielded to a block to accumulate changes for an API request.
161
175
  class Updater < ExtractJob
@@ -175,11 +189,8 @@ module Google
175
189
  storage_urls = Array(storage_files).map do |url|
176
190
  url.respond_to?(:to_gs_url) ? url.to_gs_url : url
177
191
  end
178
- dest_format = options[:format]
179
- if dest_format.nil?
180
- dest_format = Convert.derive_source_format storage_urls.first
181
- end
182
- req = Google::Apis::BigqueryV2::Job.new(
192
+ options[:format] ||= Convert.derive_source_format storage_urls.first
193
+ job = Google::Apis::BigqueryV2::Job.new(
183
194
  job_reference: job_ref,
184
195
  configuration: Google::Apis::BigqueryV2::JobConfiguration.new(
185
196
  extract: Google::Apis::BigqueryV2::JobConfigurationExtract.new(
@@ -190,12 +201,24 @@ module Google
190
201
  )
191
202
  )
192
203
 
193
- updater = ExtractJob::Updater.new req
204
+ from_job_and_options job, options
205
+ end
206
+
207
+ ##
208
+ # @private Create an Updater from a Job and options hash.
209
+ #
210
+ # @return [Google::Cloud::Bigquery::ExtractJob::Updater] A job
211
+ # configuration object for setting query options.
212
+ def self.from_job_and_options request, options = {}
213
+ updater = ExtractJob::Updater.new request
194
214
  updater.compression = options[:compression]
195
215
  updater.delimiter = options[:delimiter]
196
- updater.format = dest_format
216
+ updater.format = options[:format]
197
217
  updater.header = options[:header]
198
218
  updater.labels = options[:labels] if options[:labels]
219
+ unless options[:use_avro_logical_types].nil?
220
+ updater.use_avro_logical_types = options[:use_avro_logical_types]
221
+ end
199
222
  updater
200
223
  end
201
224
 
@@ -300,6 +323,22 @@ module Google
300
323
  @gapi.configuration.update! labels: value
301
324
  end
302
325
 
326
+ ##
327
+ # Indicate whether to enable extracting applicable column types (such
328
+ # as `TIMESTAMP`) to their corresponding AVRO logical types
329
+ # (`timestamp-micros`), instead of only using their raw types
330
+ # (`avro-long`).
331
+ #
332
+ # Only used when `#format` is set to `"AVRO"` (`#avro?`).
333
+ #
334
+ # @param [Boolean] value Whether applicable column types will use
335
+ # their corresponding AVRO logical types.
336
+ #
337
+ # @!group Attributes
338
+ def use_avro_logical_types= value
339
+ @gapi.configuration.extract.use_avro_logical_types = value
340
+ end
341
+
303
342
  ##
304
343
  # @private Returns the Google API client library version of this job.
305
344
  #
@@ -366,6 +366,82 @@ module Google
366
366
  patch_gapi! labels: new_labels
367
367
  end
368
368
 
369
+ ##
370
+ # The {EncryptionConfiguration} object that represents the custom
371
+ # encryption method used to protect this model. If not set, default
372
+ # encryption is used.
373
+ #
374
+ # Present only if this model is using custom encryption.
375
+ #
376
+ # @see https://cloud.google.com/bigquery/docs/customer-managed-encryption
377
+ # Protecting Data with Cloud KMS Keys
378
+ #
379
+ # @return [EncryptionConfiguration, nil] The encryption configuration.
380
+ #
381
+ # @!group Attributes
382
+ #
383
+ # @example
384
+ # require "google/cloud/bigquery"
385
+ #
386
+ # bigquery = Google::Cloud::Bigquery.new
387
+ # dataset = bigquery.dataset "my_dataset"
388
+ # model = dataset.model "my_model"
389
+ #
390
+ # encrypt_config = model.encryption
391
+ #
392
+ # @!group Attributes
393
+ #
394
+ def encryption
395
+ return nil if reference?
396
+ return nil if @gapi_json[:encryptionConfiguration].nil?
397
+ # We have to create a gapic object from the hash because that is what
398
+ # EncryptionConfiguration is expecing.
399
+ json_cmek = @gapi_json[:encryptionConfiguration].to_json
400
+ gapi_cmek = \
401
+ Google::Apis::BigqueryV2::EncryptionConfiguration.from_json(
402
+ json_cmek
403
+ )
404
+ EncryptionConfiguration.from_gapi(gapi_cmek).freeze
405
+ end
406
+
407
+ ##
408
+ # Set the {EncryptionConfiguration} object that represents the custom
409
+ # encryption method used to protect this model. If not set, default
410
+ # encryption is used.
411
+ #
412
+ # Present only if this model is using custom encryption.
413
+ #
414
+ # If the model is not a full resource representation (see
415
+ # {#resource_full?}), the full representation will be retrieved before
416
+ # the update to comply with ETag-based optimistic concurrency control.
417
+ #
418
+ # @see https://cloud.google.com/bigquery/docs/customer-managed-encryption
419
+ # Protecting Data with Cloud KMS Keys
420
+ #
421
+ # @param [EncryptionConfiguration] value The new encryption config.
422
+ #
423
+ # @example
424
+ # require "google/cloud/bigquery"
425
+ #
426
+ # bigquery = Google::Cloud::Bigquery.new
427
+ # dataset = bigquery.dataset "my_dataset"
428
+ # model = dataset.model "my_model"
429
+ #
430
+ # key_name = "projects/a/locations/b/keyRings/c/cryptoKeys/d"
431
+ # encrypt_config = bigquery.encryption kms_key: key_name
432
+ #
433
+ # model.encryption = encrypt_config
434
+ #
435
+ # @!group Attributes
436
+ #
437
+ def encryption= value
438
+ ensure_full_data!
439
+ # We have to create a hash from the gapic object's JSON because that
440
+ # is what Model is expecing.
441
+ json_cmek = JSON.parse value.to_gapi.to_json, symbolize_names: true
442
+ patch_gapi! encryptionConfiguration: json_cmek
443
+ end
444
+
369
445
  ##
370
446
  # The input feature columns that were used to train this model.
371
447
  #
@@ -906,7 +906,6 @@ module Google
906
906
  # {#resource_full?}), the full representation will be retrieved before
907
907
  # the update to comply with ETag-based optimistic concurrency control.
908
908
  #
909
- #
910
909
  # @see https://cloud.google.com/bigquery/docs/customer-managed-encryption
911
910
  # Protecting Data with Cloud KMS Keys
912
911
  #
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Bigquery
19
- VERSION = "1.14.1".freeze
19
+ VERSION = "1.15.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.14.1
4
+ version: 1.15.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: 2019-09-04 00:00:00.000000000 Z
12
+ date: 2019-09-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: google-cloud-core
@@ -31,14 +31,14 @@ dependencies:
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '0.26'
34
+ version: '0.31'
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.26'
41
+ version: '0.31'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: googleauth
44
44
  requirement: !ruby/object:Gem::Requirement