kura 0.3.0 → 0.4.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/.travis.yml +2 -2
- data/ChangeLog.md +9 -0
- data/kura.gemspec +0 -1
- data/lib/kura/client.rb +28 -12
- data/lib/kura/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b78afc527db0a9e07e969722760fff217c5fe1a44902dfd5862e3f32f987a6ad
|
4
|
+
data.tar.gz: a528b70819944732b406f68dd6ed242bd30c8c0a0d0cd8b02d49fb91b51b29b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53653e0444827b8c7157c1944dcf0b454c07e6df03d39baa4ebfa8ef19bef5ed3bc80bc068e32bceca349318280873b728d657fe217ce548b18c449495ba3381
|
7
|
+
data.tar.gz: a0a750a062700edf9d5ac1be5619b0ce516dd6a1d760f1c1bae0f461b3936f79b54ebeb09b0ecd139d23fe66dd90583519abd0c67f4a387f2b637aa1eda07485
|
data/.travis.yml
CHANGED
data/ChangeLog.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
# 0.4.0
|
2
|
+
|
3
|
+
## Enhancements
|
4
|
+
|
5
|
+
* Handle table whose schema without 'mode' field. The tables created by New BigQuery Web Console could have such malformed schema.
|
6
|
+
Thanks for GCPUG Slack for notice this issue.
|
7
|
+
* Add location: parameter for `job`/`cancel_job`/`wait_job` methods.
|
8
|
+
* `insert_dataset` can now create dataset with attributes like `location`.
|
9
|
+
|
1
10
|
# 0.3.0
|
2
11
|
|
3
12
|
## Enhancements
|
data/kura.gemspec
CHANGED
data/lib/kura/client.rb
CHANGED
@@ -131,7 +131,15 @@ module Kura
|
|
131
131
|
end
|
132
132
|
|
133
133
|
def insert_dataset(dataset_id, project_id: @default_project_id, &blk)
|
134
|
-
|
134
|
+
case dataset_id
|
135
|
+
when String
|
136
|
+
obj = Google::Apis::BigqueryV2::Dataset.new(dataset_reference: Google::Apis::BigqueryV2::DatasetReference.new(project_id: project_id, dataset_id: dataset_id))
|
137
|
+
when Hash
|
138
|
+
obj = Google::Apis::BigqueryV2::Dataset.new(**dataset_id)
|
139
|
+
when Google::Apis::BigqueryV2::Dataset
|
140
|
+
obj = dataset_id
|
141
|
+
end
|
142
|
+
|
135
143
|
@api.insert_dataset(project_id, obj, &blk)
|
136
144
|
rescue
|
137
145
|
process_error($!)
|
@@ -239,7 +247,7 @@ module Kura
|
|
239
247
|
end
|
240
248
|
|
241
249
|
def _convert_tabledata_field(x, field_info)
|
242
|
-
if x.nil? and field_info["mode"] == "NULLABLE"
|
250
|
+
if x.nil? and (field_info["mode"] == "NULLABLE" or field_info["mode"].nil?) # The tables created by New BigQuery Console could have schema without mode...
|
243
251
|
return nil
|
244
252
|
end
|
245
253
|
case field_info["type"]
|
@@ -290,7 +298,14 @@ module Kura
|
|
290
298
|
private :format_tabledata
|
291
299
|
|
292
300
|
def list_tabledata(dataset_id, table_id, project_id: @default_project_id, start_index: 0, max_result: 100, page_token: nil, schema: nil, &blk)
|
293
|
-
|
301
|
+
if schema.nil?
|
302
|
+
_t = table(dataset_id, table_id, project_id: project_id)
|
303
|
+
if _t
|
304
|
+
schema = table(dataset_id, table_id, project_id: project_id).schema.fields
|
305
|
+
else
|
306
|
+
raise Kura::ApiError.new("notFound", "Not found: Table #{project_id}:#{dataset_id}.#{table_id}")
|
307
|
+
end
|
308
|
+
end
|
294
309
|
schema = schema.map{|s| JSON.parse(s.to_json) }
|
295
310
|
|
296
311
|
if blk
|
@@ -333,7 +348,7 @@ module Kura
|
|
333
348
|
end
|
334
349
|
end
|
335
350
|
|
336
|
-
|
351
|
+
@api.insert_all_table_data(project_id, dataset_id, table_id, request)
|
337
352
|
rescue
|
338
353
|
process_error($!)
|
339
354
|
end
|
@@ -581,20 +596,20 @@ module Kura
|
|
581
596
|
insert_job(configuration, wait: wait, job_id: job_id, project_id: job_project_id, &blk)
|
582
597
|
end
|
583
598
|
|
584
|
-
def job(job_id, project_id: @default_project_id, &blk)
|
599
|
+
def job(job_id, location: nil, project_id: @default_project_id, &blk)
|
585
600
|
if blk
|
586
|
-
@api.get_job(project_id, job_id) do |j, e|
|
601
|
+
@api.get_job(project_id, job_id, location: location) do |j, e|
|
587
602
|
j.kura_api = self if j
|
588
603
|
blk.call(j, e)
|
589
604
|
end
|
590
605
|
else
|
591
|
-
@api.get_job(project_id, job_id).tap{|j| j.kura_api = self if j }
|
606
|
+
@api.get_job(project_id, job_id, location: location).tap{|j| j.kura_api = self if j }
|
592
607
|
end
|
593
608
|
rescue
|
594
609
|
process_error($!)
|
595
610
|
end
|
596
611
|
|
597
|
-
def cancel_job(job, project_id: @default_project_id, &blk)
|
612
|
+
def cancel_job(job, location: nil, project_id: @default_project_id, &blk)
|
598
613
|
case job
|
599
614
|
when String
|
600
615
|
jobid = job
|
@@ -605,13 +620,13 @@ module Kura
|
|
605
620
|
raise TypeError, "Kura::Client#cancel_job accept String(job-id) or Google::Apis::BigqueryV2::Job"
|
606
621
|
end
|
607
622
|
if blk
|
608
|
-
@api.cancel_job(project_id, jobid) do |r, e|
|
623
|
+
@api.cancel_job(project_id, jobid, location: location) do |r, e|
|
609
624
|
j = (r && r.job)
|
610
625
|
j.kura_api = self if j
|
611
626
|
blk.call(j, e)
|
612
627
|
end
|
613
628
|
else
|
614
|
-
@api.cancel_job(project_id, jobid).job.tap{|j| j.kura_api = self if j }
|
629
|
+
@api.cancel_job(project_id, jobid, location: location).job.tap{|j| j.kura_api = self if j }
|
615
630
|
end
|
616
631
|
end
|
617
632
|
|
@@ -631,19 +646,20 @@ module Kura
|
|
631
646
|
return false
|
632
647
|
end
|
633
648
|
|
634
|
-
def wait_job(job, timeout=60*10, project_id: @default_project_id)
|
649
|
+
def wait_job(job, timeout=60*10, location: nil, project_id: @default_project_id)
|
635
650
|
case job
|
636
651
|
when String
|
637
652
|
job_id = job
|
638
653
|
when Google::Apis::BigqueryV2::Job
|
639
654
|
project_id = job.job_reference.project_id
|
640
655
|
job_id = job.job_reference.job_id
|
656
|
+
location = job.job_reference.location
|
641
657
|
else
|
642
658
|
raise TypeError, "Kura::Client#wait_job accept String(job-id) or Google::Apis::BigqueryV2::Job"
|
643
659
|
end
|
644
660
|
expire = Time.now + timeout
|
645
661
|
while expire > Time.now
|
646
|
-
j = job(job_id, project_id: project_id)
|
662
|
+
j = job(job_id, project_id: project_id, location: location)
|
647
663
|
if job_finished?(j)
|
648
664
|
return j
|
649
665
|
end
|
data/lib/kura/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kura
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chikanaga Tomoyuki
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-api-client
|
@@ -154,8 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
154
|
- !ruby/object:Gem::Version
|
155
155
|
version: '0'
|
156
156
|
requirements: []
|
157
|
-
|
158
|
-
rubygems_version: 2.7.6
|
157
|
+
rubygems_version: 3.0.3
|
159
158
|
signing_key:
|
160
159
|
specification_version: 4
|
161
160
|
summary: Interface to BigQuery API v2.
|