google-cloud-bigquery 1.28.0 → 1.29.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 +4 -4
- data/CHANGELOG.md +6 -0
- data/CONTRIBUTING.md +1 -1
- data/LOGGING.md +1 -1
- data/lib/google/cloud/bigquery/convert.rb +0 -4
- 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 +10 -12
- 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/extract_job.rb +4 -2
- data/lib/google/cloud/bigquery/job.rb +9 -3
- data/lib/google/cloud/bigquery/job/list.rb +4 -4
- data/lib/google/cloud/bigquery/load_job.rb +1 -0
- 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 +2 -1
- data/lib/google/cloud/bigquery/project/list.rb +2 -2
- data/lib/google/cloud/bigquery/query_job.rb +24 -12
- data/lib/google/cloud/bigquery/routine.rb +1 -4
- data/lib/google/cloud/bigquery/routine/list.rb +2 -2
- data/lib/google/cloud/bigquery/service.rb +11 -13
- data/lib/google/cloud/bigquery/standard_sql.rb +4 -3
- data/lib/google/cloud/bigquery/table.rb +13 -9
- data/lib/google/cloud/bigquery/table/async_inserter.rb +24 -15
- data/lib/google/cloud/bigquery/table/list.rb +2 -2
- data/lib/google/cloud/bigquery/version.rb +1 -1
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46f8452c3539550b91ccbde1577ca5e9d7f0d7ad39976a92103590f919d23d3b
|
4
|
+
data.tar.gz: 62d2d147f332f0b0d8804eb08f7e5030b45b9068b0abb27e77987c04b670188f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e53218c1b8a8b8ce69463a78f29d27899308edb1a7c383d8b60b09080a1508b5ecb4a29f7527ebaed9c8bbdd080a2c3bf0b4a637e027aaae0c9e592c95979617
|
7
|
+
data.tar.gz: f3665ef531ed461202e9cc58214d7b7d386a2e7ab1dbe990609d5414eb2e76f1ec05ab9f54333b578c69329cd5b1da254bc1f06639ec4c82154c0db625dc40db
|
data/CHANGELOG.md
CHANGED
data/CONTRIBUTING.md
CHANGED
@@ -24,7 +24,7 @@ be able to accept your pull requests.
|
|
24
24
|
In order to use the google-cloud-bigquery console and run the project's tests,
|
25
25
|
there is a small amount of setup:
|
26
26
|
|
27
|
-
1. Install Ruby. google-cloud-bigquery requires Ruby 2.
|
27
|
+
1. Install Ruby. google-cloud-bigquery requires Ruby 2.5+. You may choose to
|
28
28
|
manage your Ruby and gem installations with [RVM](https://rvm.io/),
|
29
29
|
[rbenv](https://github.com/rbenv/rbenv), or
|
30
30
|
[chruby](https://github.com/postmodern/chruby).
|
data/LOGGING.md
CHANGED
@@ -4,7 +4,7 @@ To enable logging for this library, set the logger for the underlying [Google
|
|
4
4
|
API
|
5
5
|
Client](https://github.com/google/google-api-ruby-client/blob/master/README.md#logging)
|
6
6
|
library. The logger that you set may be a Ruby stdlib
|
7
|
-
[`Logger`](https://ruby-doc.org/stdlib
|
7
|
+
[`Logger`](https://ruby-doc.org/stdlib/libdoc/logger/rdoc/Logger.html) as
|
8
8
|
shown below, or a
|
9
9
|
[`Google::Cloud::Logging::Logger`](https://googleapis.dev/ruby/google-cloud-logging/latest)
|
10
10
|
that will write logs to [Stackdriver
|
@@ -23,8 +23,6 @@ require "date"
|
|
23
23
|
module Google
|
24
24
|
module Cloud
|
25
25
|
module Bigquery
|
26
|
-
# rubocop:disable Metrics/ModuleLength
|
27
|
-
|
28
26
|
##
|
29
27
|
# @private
|
30
28
|
#
|
@@ -378,8 +376,6 @@ module Google
|
|
378
376
|
(time_obj.to_i * 1000) + (time_obj.nsec / 1_000_000)
|
379
377
|
end
|
380
378
|
end
|
381
|
-
|
382
|
-
# rubocop:enable Metrics/ModuleLength
|
383
379
|
end
|
384
380
|
end
|
385
381
|
end
|
@@ -482,14 +482,14 @@ module Google
|
|
482
482
|
# puts row[:word]
|
483
483
|
# end
|
484
484
|
#
|
485
|
-
def all request_limit: nil
|
485
|
+
def all request_limit: nil, &block
|
486
486
|
request_limit = request_limit.to_i if request_limit
|
487
487
|
|
488
488
|
return enum_for :all, request_limit: request_limit unless block_given?
|
489
489
|
|
490
490
|
results = self
|
491
491
|
loop do
|
492
|
-
results.each
|
492
|
+
results.each(&block)
|
493
493
|
if request_limit
|
494
494
|
request_limit -= 1
|
495
495
|
break if request_limit.negative?
|
@@ -705,7 +705,7 @@ module Google
|
|
705
705
|
user_defined_function_resources: udfs_gapi(udfs)
|
706
706
|
)
|
707
707
|
}.delete_if { |_, v| v.nil? }
|
708
|
-
new_view = Google::Apis::BigqueryV2::Table.new
|
708
|
+
new_view = Google::Apis::BigqueryV2::Table.new(**new_view_opts)
|
709
709
|
|
710
710
|
gapi = service.insert_table dataset_id, new_view
|
711
711
|
Table.from_gapi gapi, service
|
@@ -779,7 +779,7 @@ module Google
|
|
779
779
|
refresh_interval_ms: refresh_interval_ms
|
780
780
|
)
|
781
781
|
}.delete_if { |_, v| v.nil? }
|
782
|
-
new_view = Google::Apis::BigqueryV2::Table.new
|
782
|
+
new_view = Google::Apis::BigqueryV2::Table.new(**new_view_opts)
|
783
783
|
|
784
784
|
gapi = service.insert_table dataset_id, new_view
|
785
785
|
Table.from_gapi gapi, service
|
@@ -2581,11 +2581,9 @@ module Google
|
|
2581
2581
|
create_table table_id do |tbl_updater|
|
2582
2582
|
yield tbl_updater if block_given?
|
2583
2583
|
end
|
2584
|
-
# rubocop:disable Lint/HandleExceptions
|
2585
2584
|
rescue Google::Cloud::AlreadyExistsError
|
2585
|
+
# Do nothing if it already exists
|
2586
2586
|
end
|
2587
|
-
# rubocop:enable Lint/HandleExceptions
|
2588
|
-
|
2589
2587
|
sleep 60
|
2590
2588
|
retry
|
2591
2589
|
end
|
@@ -2628,7 +2626,7 @@ module Google
|
|
2628
2626
|
return if attributes.empty?
|
2629
2627
|
ensure_service!
|
2630
2628
|
patch_args = Hash[attributes.map { |attr| [attr, @gapi.send(attr)] }]
|
2631
|
-
patch_gapi = Google::Apis::BigqueryV2::Dataset.new
|
2629
|
+
patch_gapi = Google::Apis::BigqueryV2::Dataset.new(**patch_args)
|
2632
2630
|
patch_gapi.etag = etag if etag
|
2633
2631
|
@gapi = service.patch_dataset dataset_id, patch_gapi
|
2634
2632
|
end
|
@@ -2757,12 +2755,11 @@ module Google
|
|
2757
2755
|
|
2758
2756
|
def load_local_or_uri file, updater
|
2759
2757
|
job_gapi = updater.to_gapi
|
2760
|
-
|
2761
|
-
|
2762
|
-
|
2763
|
-
|
2764
|
-
|
2765
|
-
job
|
2758
|
+
if local_file? file
|
2759
|
+
load_local file, job_gapi
|
2760
|
+
else
|
2761
|
+
load_storage file, job_gapi
|
2762
|
+
end
|
2766
2763
|
end
|
2767
2764
|
|
2768
2765
|
def storage_url? files
|
@@ -2802,6 +2799,7 @@ module Google
|
|
2802
2799
|
##
|
2803
2800
|
# @private Create an Updater object.
|
2804
2801
|
def initialize gapi
|
2802
|
+
super()
|
2805
2803
|
@updates = []
|
2806
2804
|
@gapi = gapi
|
2807
2805
|
end
|
@@ -1194,7 +1194,7 @@ module Google
|
|
1194
1194
|
@rules.reject!(&find_by_scope_and_value(scope, value))
|
1195
1195
|
# Add new rule for this role, scope, and value
|
1196
1196
|
opts = { role: role, scope => value }
|
1197
|
-
@rules << Google::Apis::BigqueryV2::Dataset::Access.new(opts)
|
1197
|
+
@rules << Google::Apis::BigqueryV2::Dataset::Access.new(**opts)
|
1198
1198
|
end
|
1199
1199
|
|
1200
1200
|
# @private
|
@@ -1204,7 +1204,7 @@ module Google
|
|
1204
1204
|
@rules.reject!(&find_by_scope_and_resource_ref(:routine, value))
|
1205
1205
|
# Add new rule for this role, scope, and value
|
1206
1206
|
opts = { routine: value }
|
1207
|
-
@rules << Google::Apis::BigqueryV2::Dataset::Access.new(opts)
|
1207
|
+
@rules << Google::Apis::BigqueryV2::Dataset::Access.new(**opts)
|
1208
1208
|
end
|
1209
1209
|
|
1210
1210
|
# @private
|
@@ -1215,7 +1215,7 @@ module Google
|
|
1215
1215
|
@rules.reject!(&find_by_scope_and_resource_ref(:view, value))
|
1216
1216
|
# Add new rule for this role, scope, and value
|
1217
1217
|
opts = { view: value }
|
1218
|
-
@rules << Google::Apis::BigqueryV2::Dataset::Access.new(opts)
|
1218
|
+
@rules << Google::Apis::BigqueryV2::Dataset::Access.new(**opts)
|
1219
1219
|
end
|
1220
1220
|
|
1221
1221
|
# @private
|
@@ -120,12 +120,12 @@ module Google
|
|
120
120
|
# puts dataset.name
|
121
121
|
# end
|
122
122
|
#
|
123
|
-
def all request_limit: nil
|
123
|
+
def all request_limit: nil, &block
|
124
124
|
request_limit = request_limit.to_i if request_limit
|
125
125
|
return enum_for :all, request_limit: request_limit unless block_given?
|
126
126
|
results = self
|
127
127
|
loop do
|
128
|
-
results.each
|
128
|
+
results.each(&block)
|
129
129
|
if request_limit
|
130
130
|
request_limit -= 1
|
131
131
|
break if request_limit.negative?
|
@@ -246,6 +246,7 @@ module Google
|
|
246
246
|
##
|
247
247
|
# @private Create an Updater object.
|
248
248
|
def initialize gapi
|
249
|
+
super()
|
249
250
|
@gapi = gapi
|
250
251
|
end
|
251
252
|
|
@@ -263,9 +264,10 @@ module Google
|
|
263
264
|
extract_config = Google::Apis::BigqueryV2::JobConfigurationExtract.new(
|
264
265
|
destination_uris: Array(storage_urls)
|
265
266
|
)
|
266
|
-
|
267
|
+
case source
|
268
|
+
when Google::Apis::BigqueryV2::TableReference
|
267
269
|
extract_config.source_table = source
|
268
|
-
|
270
|
+
when Google::Apis::BigqueryV2::ModelReference
|
269
271
|
extract_config.source_model = source
|
270
272
|
end
|
271
273
|
job = Google::Apis::BigqueryV2::Job.new(
|
@@ -507,7 +507,8 @@ module Google
|
|
507
507
|
# @attr_reader [Fixnum] slot_ms The slot-milliseconds the job spent in the given reservation.
|
508
508
|
#
|
509
509
|
class ReservationUsage
|
510
|
-
attr_reader :name
|
510
|
+
attr_reader :name
|
511
|
+
attr_reader :slot_ms
|
511
512
|
|
512
513
|
##
|
513
514
|
# @private Creates a new ReservationUsage instance.
|
@@ -571,7 +572,8 @@ module Google
|
|
571
572
|
# end
|
572
573
|
#
|
573
574
|
class ScriptStatistics
|
574
|
-
attr_reader :evaluation_kind
|
575
|
+
attr_reader :evaluation_kind
|
576
|
+
attr_reader :stack_frames
|
575
577
|
|
576
578
|
##
|
577
579
|
# @private Creates a new ScriptStatistics instance.
|
@@ -636,7 +638,11 @@ module Google
|
|
636
638
|
# end
|
637
639
|
#
|
638
640
|
class ScriptStackFrame
|
639
|
-
attr_reader :start_line
|
641
|
+
attr_reader :start_line
|
642
|
+
attr_reader :start_column
|
643
|
+
attr_reader :end_line
|
644
|
+
attr_reader :end_column
|
645
|
+
attr_reader :text
|
640
646
|
|
641
647
|
##
|
642
648
|
# @private Creates a new ScriptStackFrame instance.
|
@@ -72,8 +72,8 @@ module Google
|
|
72
72
|
return nil unless next?
|
73
73
|
ensure_service!
|
74
74
|
next_kwargs = @kwargs.merge token: token
|
75
|
-
next_gapi = @service.list_jobs
|
76
|
-
self.class.from_gapi next_gapi, @service, next_kwargs
|
75
|
+
next_gapi = @service.list_jobs(**next_kwargs)
|
76
|
+
self.class.from_gapi next_gapi, @service, **next_kwargs
|
77
77
|
end
|
78
78
|
|
79
79
|
##
|
@@ -121,12 +121,12 @@ module Google
|
|
121
121
|
# puts job.state
|
122
122
|
# end
|
123
123
|
#
|
124
|
-
def all request_limit: nil
|
124
|
+
def all request_limit: nil, &block
|
125
125
|
request_limit = request_limit.to_i if request_limit
|
126
126
|
return enum_for :all, request_limit: request_limit unless block_given?
|
127
127
|
results = self
|
128
128
|
loop do
|
129
|
-
results.each
|
129
|
+
results.each(&block)
|
130
130
|
if request_limit
|
131
131
|
request_limit -= 1
|
132
132
|
break if request_limit.negative?
|
@@ -124,12 +124,12 @@ module Google
|
|
124
124
|
# puts model.model_id
|
125
125
|
# end
|
126
126
|
#
|
127
|
-
def all request_limit: nil
|
127
|
+
def all request_limit: nil, &block
|
128
128
|
request_limit = request_limit.to_i if request_limit
|
129
129
|
return enum_for :all, request_limit: request_limit unless block_given?
|
130
130
|
results = self
|
131
131
|
loop do
|
132
|
-
results.each
|
132
|
+
results.each(&block)
|
133
133
|
if request_limit
|
134
134
|
request_limit -= 1
|
135
135
|
break if request_limit.negative?
|
@@ -121,12 +121,12 @@ module Google
|
|
121
121
|
# puts project.name
|
122
122
|
# end
|
123
123
|
#
|
124
|
-
def all request_limit: nil
|
124
|
+
def all request_limit: nil, &block
|
125
125
|
request_limit = request_limit.to_i if request_limit
|
126
126
|
return enum_for :all, request_limit: request_limit unless block_given?
|
127
127
|
results = self
|
128
128
|
loop do
|
129
|
-
results.each
|
129
|
+
results.each(&block)
|
130
130
|
if request_limit
|
131
131
|
request_limit -= 1
|
132
132
|
break if request_limit.negative?
|
@@ -692,8 +692,11 @@ module Google
|
|
692
692
|
end
|
693
693
|
ensure_schema!
|
694
694
|
|
695
|
-
|
696
|
-
|
695
|
+
data_hash = service.list_tabledata destination_table_dataset_id,
|
696
|
+
destination_table_table_id,
|
697
|
+
token: token,
|
698
|
+
max: max,
|
699
|
+
start: start
|
697
700
|
Data.from_gapi_json data_hash, destination_table_gapi, @gapi, service
|
698
701
|
end
|
699
702
|
alias query_results data
|
@@ -704,12 +707,11 @@ module Google
|
|
704
707
|
##
|
705
708
|
# @private Create an Updater object.
|
706
709
|
def initialize service, gapi
|
710
|
+
super()
|
707
711
|
@service = service
|
708
712
|
@gapi = gapi
|
709
713
|
end
|
710
714
|
|
711
|
-
# rubocop:disable all
|
712
|
-
|
713
715
|
##
|
714
716
|
# @private Create an Updater from an options hash.
|
715
717
|
#
|
@@ -748,8 +750,6 @@ module Google
|
|
748
750
|
updater
|
749
751
|
end
|
750
752
|
|
751
|
-
# rubocop:enable all
|
752
|
-
|
753
753
|
##
|
754
754
|
# Sets the geographic location where the job should run. Required
|
755
755
|
# except for US and EU.
|
@@ -935,13 +935,13 @@ module Google
|
|
935
935
|
raise ArgumentError, "types must use the same format as params" if types.class != params.class
|
936
936
|
|
937
937
|
case params
|
938
|
-
when Array
|
938
|
+
when Array
|
939
939
|
@gapi.configuration.query.use_legacy_sql = false
|
940
940
|
@gapi.configuration.query.parameter_mode = "POSITIONAL"
|
941
941
|
@gapi.configuration.query.query_parameters = params.zip(types).map do |param, type|
|
942
942
|
Convert.to_query_param param, type
|
943
943
|
end
|
944
|
-
when Hash
|
944
|
+
when Hash
|
945
945
|
@gapi.configuration.query.use_legacy_sql = false
|
946
946
|
@gapi.configuration.query.parameter_mode = "NAMED"
|
947
947
|
@gapi.configuration.query.query_parameters = params.map do |name, param|
|
@@ -1592,9 +1592,20 @@ module Google
|
|
1592
1592
|
# end
|
1593
1593
|
#
|
1594
1594
|
class Stage
|
1595
|
-
attr_reader :compute_ratio_avg
|
1596
|
-
|
1597
|
-
|
1595
|
+
attr_reader :compute_ratio_avg
|
1596
|
+
attr_reader :compute_ratio_max
|
1597
|
+
attr_reader :id
|
1598
|
+
attr_reader :name
|
1599
|
+
attr_reader :read_ratio_avg
|
1600
|
+
attr_reader :read_ratio_max
|
1601
|
+
attr_reader :records_read
|
1602
|
+
attr_reader :records_written
|
1603
|
+
attr_reader :status
|
1604
|
+
attr_reader :steps
|
1605
|
+
attr_reader :wait_ratio_avg
|
1606
|
+
attr_reader :wait_ratio_max
|
1607
|
+
attr_reader :write_ratio_avg
|
1608
|
+
attr_reader :write_ratio_max
|
1598
1609
|
|
1599
1610
|
##
|
1600
1611
|
# @private Creates a new Stage instance.
|
@@ -1657,7 +1668,8 @@ module Google
|
|
1657
1668
|
# end
|
1658
1669
|
#
|
1659
1670
|
class Step
|
1660
|
-
attr_reader :kind
|
1671
|
+
attr_reader :kind
|
1672
|
+
attr_reader :substeps
|
1661
1673
|
|
1662
1674
|
##
|
1663
1675
|
# @private Creates a new Stage instance.
|
@@ -1006,6 +1006,7 @@ module Google
|
|
1006
1006
|
##
|
1007
1007
|
# @private Create an Updater object.
|
1008
1008
|
def initialize gapi
|
1009
|
+
super()
|
1009
1010
|
@original_gapi = gapi
|
1010
1011
|
@gapi = gapi.dup
|
1011
1012
|
end
|
@@ -1210,15 +1211,11 @@ module Google
|
|
1210
1211
|
end
|
1211
1212
|
alias refresh! reload!
|
1212
1213
|
|
1213
|
-
# rubocop:disable Style/CaseEquality
|
1214
|
-
|
1215
1214
|
# @private
|
1216
1215
|
def updates?
|
1217
1216
|
!(@gapi === @original_gapi)
|
1218
1217
|
end
|
1219
1218
|
|
1220
|
-
# rubocop:enable Style/CaseEquality
|
1221
|
-
|
1222
1219
|
# @private
|
1223
1220
|
def to_gapi
|
1224
1221
|
@gapi
|
@@ -124,12 +124,12 @@ module Google
|
|
124
124
|
# puts routine.routine_id
|
125
125
|
# end
|
126
126
|
#
|
127
|
-
def all request_limit: nil
|
127
|
+
def all request_limit: nil, &block
|
128
128
|
request_limit = request_limit.to_i if request_limit
|
129
129
|
return enum_for :all, request_limit: request_limit unless block_given?
|
130
130
|
results = self
|
131
131
|
loop do
|
132
|
-
results.each
|
132
|
+
results.each(&block)
|
133
133
|
if request_limit
|
134
134
|
request_limit -= 1
|
135
135
|
break if request_limit.negative?
|
@@ -483,7 +483,7 @@ module Google
|
|
483
483
|
table_id: m["tbl"]
|
484
484
|
}.delete_if { |_, v| v.nil? }
|
485
485
|
str_table_ref_hash = default_ref.to_h.merge str_table_ref_hash
|
486
|
-
ref = Google::Apis::BigqueryV2::TableReference.new
|
486
|
+
ref = Google::Apis::BigqueryV2::TableReference.new(**str_table_ref_hash)
|
487
487
|
validate_table_ref ref
|
488
488
|
ref
|
489
489
|
end
|
@@ -554,9 +554,9 @@ module Google
|
|
554
554
|
nil
|
555
555
|
end
|
556
556
|
|
557
|
-
def execute backoff: nil
|
557
|
+
def execute backoff: nil, &block
|
558
558
|
if backoff
|
559
|
-
Backoff.new(retries: retries).execute
|
559
|
+
Backoff.new(retries: retries).execute(&block)
|
560
560
|
else
|
561
561
|
yield
|
562
562
|
end
|
@@ -590,22 +590,20 @@ module Google
|
|
590
590
|
def execute
|
591
591
|
current_retries = 0
|
592
592
|
loop do
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
current_retries += 1
|
600
|
-
end
|
593
|
+
return yield
|
594
|
+
rescue Google::Apis::Error => e
|
595
|
+
raise e unless retry? e.body, current_retries
|
596
|
+
|
597
|
+
@backoff.call current_retries
|
598
|
+
current_retries += 1
|
601
599
|
end
|
602
600
|
end
|
603
601
|
|
604
602
|
protected
|
605
603
|
|
606
604
|
def retry? result, current_retries #:nodoc:
|
607
|
-
if current_retries < @retries
|
608
|
-
return true
|
605
|
+
if current_retries < @retries && retry_error_reason?(result)
|
606
|
+
return true
|
609
607
|
end
|
610
608
|
false
|
611
609
|
end
|
@@ -401,11 +401,12 @@ module Google
|
|
401
401
|
# @private New Google::Apis::BigqueryV2::StandardSqlDataType from a String or StandardSql::DataType object.
|
402
402
|
def self.gapi_from_string_or_data_type data_type
|
403
403
|
return if data_type.nil?
|
404
|
-
|
404
|
+
case data_type
|
405
|
+
when StandardSql::DataType
|
405
406
|
data_type.to_gapi
|
406
|
-
|
407
|
+
when Hash
|
407
408
|
data_type
|
408
|
-
|
409
|
+
when String, Symbol
|
409
410
|
Google::Apis::BigqueryV2::StandardSqlDataType.new type_kind: data_type.to_s.upcase
|
410
411
|
else
|
411
412
|
raise ArgumentError, "Unable to convert #{data_type} to Google::Apis::BigqueryV2::StandardSqlDataType"
|
@@ -2374,8 +2374,12 @@ module Google
|
|
2374
2374
|
end
|
2375
2375
|
|
2376
2376
|
ensure_service!
|
2377
|
-
|
2378
|
-
|
2377
|
+
gapi = service.insert_tabledata dataset_id,
|
2378
|
+
table_id,
|
2379
|
+
rows,
|
2380
|
+
skip_invalid: skip_invalid,
|
2381
|
+
ignore_unknown: ignore_unknown,
|
2382
|
+
insert_ids: insert_ids
|
2379
2383
|
InsertResponse.from_gapi rows, gapi
|
2380
2384
|
end
|
2381
2385
|
|
@@ -2674,7 +2678,7 @@ module Google
|
|
2674
2678
|
return if attributes.empty?
|
2675
2679
|
ensure_service!
|
2676
2680
|
patch_args = Hash[attributes.map { |attr| [attr, @gapi.send(attr)] }]
|
2677
|
-
patch_gapi = Google::Apis::BigqueryV2::Table.new
|
2681
|
+
patch_gapi = Google::Apis::BigqueryV2::Table.new(**patch_args)
|
2678
2682
|
patch_gapi.etag = etag if etag
|
2679
2683
|
@gapi = service.patch_table dataset_id, table_id, patch_gapi
|
2680
2684
|
|
@@ -2800,12 +2804,11 @@ module Google
|
|
2800
2804
|
|
2801
2805
|
def load_local_or_uri file, updater
|
2802
2806
|
job_gapi = updater.to_gapi
|
2803
|
-
|
2804
|
-
|
2805
|
-
|
2806
|
-
|
2807
|
-
|
2808
|
-
job
|
2807
|
+
if local_file? file
|
2808
|
+
load_local file, job_gapi
|
2809
|
+
else
|
2810
|
+
load_storage file, job_gapi
|
2811
|
+
end
|
2809
2812
|
end
|
2810
2813
|
|
2811
2814
|
def storage_url? files
|
@@ -2858,6 +2861,7 @@ module Google
|
|
2858
2861
|
##
|
2859
2862
|
# @private Create an Updater object.
|
2860
2863
|
def initialize gapi
|
2864
|
+
super()
|
2861
2865
|
@updates = []
|
2862
2866
|
@gapi = gapi
|
2863
2867
|
@schema = nil
|
@@ -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
|
@@ -265,18 +268,19 @@ module Google
|
|
265
268
|
json_rows = @batch.json_rows
|
266
269
|
insert_ids = @batch.insert_ids
|
267
270
|
Concurrent::Future.new executor: @thread_pool do
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
271
|
+
raise ArgumentError, "No rows provided" if json_rows.empty?
|
272
|
+
insert_resp = @table.service.insert_tabledata_json_rows @table.dataset_id,
|
273
|
+
@table.table_id,
|
274
|
+
json_rows,
|
275
|
+
skip_invalid: @skip_invalid,
|
276
|
+
ignore_unknown: @ignore_unknown,
|
277
|
+
insert_ids: insert_ids
|
278
|
+
|
279
|
+
result = Result.new InsertResponse.from_gapi(orig_rows, insert_resp)
|
280
|
+
rescue StandardError => e
|
281
|
+
result = Result.new nil, e
|
282
|
+
ensure
|
283
|
+
@callback&.call result
|
280
284
|
end.execute
|
281
285
|
|
282
286
|
@batch = nil
|
@@ -286,7 +290,11 @@ module Google
|
|
286
290
|
##
|
287
291
|
# @private
|
288
292
|
class Batch
|
289
|
-
attr_reader :max_bytes
|
293
|
+
attr_reader :max_bytes
|
294
|
+
attr_reader :max_rows
|
295
|
+
attr_reader :rows
|
296
|
+
attr_reader :json_rows
|
297
|
+
attr_reader :insert_ids
|
290
298
|
|
291
299
|
def initialize max_bytes: 10_000_000, max_rows: 500
|
292
300
|
@max_bytes = max_bytes
|
@@ -395,7 +403,8 @@ module Google
|
|
395
403
|
@error = error
|
396
404
|
end
|
397
405
|
|
398
|
-
attr_reader :insert_response
|
406
|
+
attr_reader :insert_response
|
407
|
+
attr_reader :error
|
399
408
|
|
400
409
|
##
|
401
410
|
# 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.29.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: 2021-03-
|
12
|
+
date: 2021-03-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: concurrent-ruby
|
@@ -40,33 +40,33 @@ dependencies:
|
|
40
40
|
- !ruby/object:Gem::Version
|
41
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,7 +284,7 @@ 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
|
- - ">="
|