google-cloud-bigquery 1.12.0 → 1.13.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4fb1722765075dded454afdeea337efe2c088c118f6f966c55a84ff9bb065df1
4
- data.tar.gz: 2884b2a12b6a5137234dd4a3fd1fc2420ed2c05eaae223ebeae285caa1ba44b8
3
+ metadata.gz: 5749ebc4d81b2e758eea899e5e13f8d1852c51b2a7076ed5eb853920b690beb3
4
+ data.tar.gz: abdade7b534e45a3522b5572b41d899c5a5c88b92d14932804e272d13740efaf
5
5
  SHA512:
6
- metadata.gz: 851560e73e7e1f48b58e08f99ada6f2f822f33f9dfe246e19b6d3abec4b0bfb2ef4802f402e2951ca0e40cb966be2981930fb62608f81d5a57edfa6ae5626d1f
7
- data.tar.gz: b1a0dc302400edfe2a499d0299cc913cf85e4f34e29b460b8f5b3564a33b0e9a13c99d37539cc65afee07b4cbcfd7103bb07b4898866ea68dcab2187105ead1a
6
+ metadata.gz: e0d63cd756ed4361f7dfcfb85f2adadad578f932c5d06cab802803d8a9a82a7e7274089716e8ad580f2cbaa2d21b6b7db898a9be833aa6f4aac161c0549df103
7
+ data.tar.gz: 959b228436b7d9fc601380b5fa93254a8e317275dc04c9014535cd244694277d0334d76110e1eed48891d774cb66d2f19a41e6da89a8e9527a523ad1e32a73c4
@@ -1,5 +1,13 @@
1
1
  # Release History
2
2
 
3
+ ### 1.13.0 / 2019-07-31
4
+
5
+ * Add Table#require_partition_filter
6
+ * List jobs using min and max created_at
7
+ * Reduce thread usage at startup
8
+ * Allocate threads in pool as needed, not all up front
9
+ * Update documentation links
10
+
3
11
  ### 1.12.0 / 2019-07-10
4
12
 
5
13
  * Add BigQuery Model API
@@ -34,7 +42,7 @@
34
42
  * Add copy and extract methods to Project
35
43
  * Add Project#extract and Project#extract_job
36
44
  * Add Project#copy and Project#copy_job
37
- * Deprecate dryrun param in Table#copy_job, Table#extract_job and
45
+ * Deprecate dryrun param in Table#copy_job, Table#extract_job and
38
46
  Table#load_job
39
47
  * Fix memoization in Dataset#exists? and Table#exists?
40
48
  * Add force param to Dataset#exists? and Table#exists?
data/LOGGING.md CHANGED
@@ -6,7 +6,7 @@ Client](https://github.com/google/google-api-ruby-client/blob/master/README.md#l
6
6
  library. The logger that you set may be a Ruby stdlib
7
7
  [`Logger`](https://ruby-doc.org/stdlib-2.4.0/libdoc/logger/rdoc/Logger.html) as
8
8
  shown below, or a
9
- [`Google::Cloud::Logging::Logger`](https://googleapis.github.io/google-cloud-ruby/docs/google-cloud-logging/latest/Google/Cloud/Logging/Logger)
9
+ [`Google::Cloud::Logging::Logger`](https://googleapis.dev/ruby/google-cloud-logging/latest)
10
10
  that will write logs to [Stackdriver
11
11
  Logging](https://cloud.google.com/logging/).
12
12
 
@@ -71,9 +71,9 @@ module Google
71
71
  def next
72
72
  return nil unless next?
73
73
  ensure_service!
74
- options = { all: @hidden, token: token, max: @max, filter: @filter }
75
- gapi = @service.list_jobs options
76
- self.class.from_gapi gapi, @service, @hidden, @max, @filter
74
+ next_options = @options.merge token: token
75
+ next_gapi = @service.list_jobs next_options
76
+ self.class.from_gapi next_gapi, @service, next_options
77
77
  end
78
78
 
79
79
  ##
@@ -141,17 +141,14 @@ module Google
141
141
  ##
142
142
  # @private New Job::List from a Google API Client
143
143
  # Google::Apis::BigqueryV2::JobList object.
144
- def self.from_gapi gapi_list, service, hidden = nil, max = nil,
145
- filter = nil
144
+ def self.from_gapi gapi_list, service, options = {}
146
145
  jobs = List.new(Array(gapi_list.jobs).map do |gapi_object|
147
146
  Job.from_gapi gapi_object, service
148
147
  end)
149
- jobs.instance_variable_set :@token, gapi_list.next_page_token
150
- jobs.instance_variable_set :@etag, gapi_list.etag
151
- jobs.instance_variable_set :@service, service
152
- jobs.instance_variable_set :@hidden, hidden
153
- jobs.instance_variable_set :@max, max
154
- jobs.instance_variable_set :@filter, filter
148
+ jobs.instance_variable_set :@token, gapi_list.next_page_token
149
+ jobs.instance_variable_set :@etag, gapi_list.etag
150
+ jobs.instance_variable_set :@service, service
151
+ jobs.instance_variable_set :@options, options
155
152
  jobs
156
153
  end
157
154
 
@@ -1024,11 +1024,17 @@ module Google
1024
1024
  # Retrieves the list of jobs belonging to the project.
1025
1025
  #
1026
1026
  # @param [Boolean] all Whether to display jobs owned by all users in the
1027
- # project. The default is `false`.
1027
+ # project. The default is `false`. Optional.
1028
1028
  # @param [String] token A previously-returned page token representing
1029
- # part of the larger set of results to view.
1030
- # @param [Integer] max Maximum number of jobs to return.
1031
- # @param [String] filter A filter for job state.
1029
+ # part of the larger set of results to view. Optional.
1030
+ # @param [Integer] max Maximum number of jobs to return. Optional.
1031
+ # @param [String] filter A filter for job state. Optional.
1032
+ # @param [Time] min_created_at Min value for {Job#created_at}. When
1033
+ # provided, only jobs created after or at this time are returned.
1034
+ # Optional.
1035
+ # @param [Time] max_created_at Max value for {Job#created_at}. When
1036
+ # provided, only jobs created before or at this time are returned.
1037
+ # Optional.
1032
1038
  #
1033
1039
  # Acceptable values are:
1034
1040
  #
@@ -1059,6 +1065,20 @@ module Google
1059
1065
  # # process job
1060
1066
  # end
1061
1067
  #
1068
+ # @example Retrieve only jobs created within provided times:
1069
+ # require "google/cloud/bigquery"
1070
+ #
1071
+ # bigquery = Google::Cloud::Bigquery.new
1072
+ #
1073
+ # two_days_ago = Time.now - 60*60*24*2
1074
+ # three_days_ago = Time.now - 60*60*24*3
1075
+ #
1076
+ # jobs = bigquery.jobs min_created_at: three_days_ago,
1077
+ # max_created_at: two_days_ago
1078
+ # jobs.each do |job|
1079
+ # # process job
1080
+ # end
1081
+ #
1062
1082
  # @example Retrieve all jobs: (See {Job::List#all})
1063
1083
  # require "google/cloud/bigquery"
1064
1084
  #
@@ -1069,11 +1089,15 @@ module Google
1069
1089
  # # process job
1070
1090
  # end
1071
1091
  #
1072
- def jobs all: nil, token: nil, max: nil, filter: nil
1092
+ def jobs all: nil, token: nil, max: nil, filter: nil,
1093
+ min_created_at: nil, max_created_at: nil
1073
1094
  ensure_service!
1074
- options = { all: all, token: token, max: max, filter: filter }
1095
+ options = {
1096
+ all: all, token: token, max: max, filter: filter,
1097
+ min_created_at: min_created_at, max_created_at: max_created_at
1098
+ }
1075
1099
  gapi = service.list_jobs options
1076
- Job::List.from_gapi gapi, service, all, max, filter
1100
+ Job::List.from_gapi gapi, service, options
1077
1101
  end
1078
1102
 
1079
1103
  ##
@@ -297,11 +297,15 @@ module Google
297
297
  # been granted the READER job role.
298
298
  def list_jobs options = {}
299
299
  # The list operation is considered idempotent
300
+ min_creation_time = Convert.time_to_millis options[:min_created_at]
301
+ max_creation_time = Convert.time_to_millis options[:max_created_at]
300
302
  execute backoff: true do
301
303
  service.list_jobs \
302
304
  @project, all_users: options[:all], max_results: options[:max],
303
305
  page_token: options[:token], projection: "full",
304
- state_filter: options[:filter]
306
+ state_filter: options[:filter],
307
+ min_creation_time: min_creation_time,
308
+ max_creation_time: max_creation_time
305
309
  end
306
310
  end
307
311
 
@@ -325,6 +325,52 @@ module Google
325
325
  patch_gapi! :time_partitioning
326
326
  end
327
327
 
328
+ ###
329
+ # Whether queries over this table require a partition filter that can be
330
+ # used for partition elimination to be specified. See [Partitioned
331
+ # Tables](https://cloud.google.com/bigquery/docs/partitioned-tables).
332
+ #
333
+ # @return [Boolean, nil] `true` when a partition filter will be
334
+ # required, `false` otherwise, or `nil` if the object is a reference
335
+ # (see {#reference?}).
336
+ #
337
+ # @!group Attributes
338
+ #
339
+ def require_partition_filter
340
+ return nil if reference?
341
+ ensure_full_data!
342
+ @gapi.require_partition_filter
343
+ end
344
+
345
+ ##
346
+ # Sets whether queries over this table require a partition filter. See
347
+ # [Partitioned
348
+ # Tables](https://cloud.google.com/bigquery/docs/partitioned-tables).
349
+ #
350
+ # If the table is not a full resource representation (see
351
+ # {#resource_full?}), the full representation will be retrieved before
352
+ # the update to comply with ETag-based optimistic concurrency control.
353
+ #
354
+ # @param [Boolean] new_require Whether queries over this table require a
355
+ # partition filter.
356
+ #
357
+ # @example
358
+ # require "google/cloud/bigquery"
359
+ #
360
+ # bigquery = Google::Cloud::Bigquery.new
361
+ # dataset = bigquery.dataset "my_dataset"
362
+ # table = dataset.create_table "my_table" do |table|
363
+ # table.require_partition_filter = true
364
+ # end
365
+ #
366
+ # @!group Attributes
367
+ #
368
+ def require_partition_filter= new_require
369
+ reload! unless resource_full?
370
+ @gapi.require_partition_filter = new_require
371
+ patch_gapi! :require_partition_filter
372
+ end
373
+
328
374
  ###
329
375
  # Checks if the table is clustered.
330
376
  #
@@ -86,7 +86,8 @@ module Google
86
86
 
87
87
  @batch = nil
88
88
 
89
- @thread_pool = Concurrent::FixedThreadPool.new @threads
89
+ @thread_pool = Concurrent::ThreadPoolExecutor.new \
90
+ max_threads: @threads
90
91
 
91
92
  @cond = new_cond
92
93
 
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Bigquery
19
- VERSION = "1.12.0".freeze
19
+ VERSION = "1.13.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.12.0
4
+ version: 1.13.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-07-10 00:00:00.000000000 Z
12
+ date: 2019-08-01 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.23'
34
+ version: '0.26'
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.23'
41
+ version: '0.26'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: googleauth
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -293,7 +293,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
293
293
  - !ruby/object:Gem::Version
294
294
  version: '0'
295
295
  requirements: []
296
- rubygems_version: 3.0.3
296
+ rubygems_version: 3.0.4
297
297
  signing_key:
298
298
  specification_version: 4
299
299
  summary: API Client library for Google BigQuery