kura 0.3.0 → 0.4.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: 26b74b2d5b3f3a62af67cd8f33fda5418dac09c02f32e0f8ecfdce26ccccda9c
4
- data.tar.gz: a93854b4c824c5d4215ae0dcfa39292a4a09ff34518415893ca6056e42503c04
3
+ metadata.gz: b78afc527db0a9e07e969722760fff217c5fe1a44902dfd5862e3f32f987a6ad
4
+ data.tar.gz: a528b70819944732b406f68dd6ed242bd30c8c0a0d0cd8b02d49fb91b51b29b1
5
5
  SHA512:
6
- metadata.gz: f196e24d33c2421d57efb3d76f51975fac64540be475aa1c3f364287370bbcbc268f59eb8f498ff85de5d17fd0ef11037679fd3ce73c4af1da285f895eae6d02
7
- data.tar.gz: 40ee5ccca20fb9882d09786ce78096034d3b6ae3fc9bfa3cfe926dfefe9c149b3bed382002e3f82f4119775d2d603ebfe8f63f87285b59fb73c2852ce3670f47
6
+ metadata.gz: 53653e0444827b8c7157c1944dcf0b454c07e6df03d39baa4ebfa8ef19bef5ed3bc80bc068e32bceca349318280873b728d657fe217ce548b18c449495ba3381
7
+ data.tar.gz: a0a750a062700edf9d5ac1be5619b0ce516dd6a1d760f1c1bae0f461b3936f79b54ebeb09b0ecd139d23fe66dd90583519abd0c67f4a387f2b637aa1eda07485
@@ -1,5 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.5.5
4
- - 2.6.3
3
+ - 2.5.7
4
+ - 2.6.5
5
5
  before_install: gem install bundler -v 1.17.1
@@ -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
@@ -18,7 +18,6 @@ Gem::Specification.new do |spec|
18
18
  spec.bindir = "exe"
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
- spec.has_rdoc = false
22
21
 
23
22
  spec.required_ruby_version = '>= 2.1'
24
23
 
@@ -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
- obj = Google::Apis::BigqueryV2::Dataset.new(dataset_reference: Google::Apis::BigqueryV2::DatasetReference.new(project_id: project_id, dataset_id: dataset_id))
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
- schema ||= table(dataset_id, table_id, project_id: project_id).schema.fields
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
- r = @api.insert_all_table_data(project_id, dataset_id, table_id, request)
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
@@ -1,3 +1,3 @@
1
1
  module Kura
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
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.3.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-05-15 00:00:00.000000000 Z
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
- rubyforge_project:
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.