bigquery-client 0.3.3 → 0.3.4

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
  SHA1:
3
- metadata.gz: 62916ca2e9ee1f90227ea2f2e67c9cd4f26c316d
4
- data.tar.gz: f763e852a5747075a16c6a33c6c9287d3ee8d577
3
+ metadata.gz: dcdf35c7bc17562e5cdd590bdbac3d6ae9df055d
4
+ data.tar.gz: 206728dd2bd10c4bda55ce79857e73b6c6f9d85b
5
5
  SHA512:
6
- metadata.gz: 383fd4cd1bfe5903d6689eafd06478ebd43441f2ddf61c24901e108c5e590c7f338122d59e3c95f01f1bafd57da8817efe794f8129af39b6190243a39b8f27fc
7
- data.tar.gz: fe4db299be123fe3c5b7c7310a1d79d4bcd53456a98d8e780085b27cef6ba32b4c23bb46135b8fea04c4ebe5084464e880083a7ad740ed8cdfe5099afa5f3404
6
+ metadata.gz: 8a23eff48fd905f4de17ce835e2d7c7c3b85a8e31be65c23949b41640c846aa4061e1ecdb1b9661c83aba6e2e052323c41ac1117a39f87d1fa305b2bf676f6fd
7
+ data.tar.gz: c944d45ce22b57b5566b2218aa85baa4ca03e5541d8b10f6bcb9d50d5171a7c54e8d4b2afe40e649067996194f82fe2d6cfa812c5617dba989635c6ab4f35660
data/Gemfile CHANGED
@@ -1,3 +1,15 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ group :development, :test do
4
+ gem 'dotenv', '~> 1.0.0'
5
+ gem 'awesome_print'
6
+ gem 'pry'
7
+ gem 'pry-doc'
8
+ gem 'pry-byebug'
9
+ end
10
+
11
+ group :test do
12
+ gem 'test-unit', '~> 3.0.0'
13
+ end
14
+
3
15
  gemspec
@@ -22,10 +22,4 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_development_dependency 'rake'
24
24
  spec.add_development_dependency 'bundler'
25
- spec.add_development_dependency 'test-unit', '~> 3.0.0'
26
- spec.add_development_dependency 'dotenv', '~> 1.0.0'
27
- spec.add_development_dependency 'awesome_print'
28
- spec.add_development_dependency 'pry'
29
- spec.add_development_dependency 'pry-doc'
30
- spec.add_development_dependency 'pry-byebug'
31
25
  end
@@ -4,15 +4,15 @@ module BigQuery
4
4
  module Jobs
5
5
  def sql(query, options = {})
6
6
  jobs_query_response = jobs_query(query, options)
7
- names = jobs_query_response['schema']['fields'].map {|field| field['name'] }
8
- types = jobs_query_response['schema']['fields'].map {|field| field['type'] }
7
+ fields = jobs_query_response['schema']['fields']
8
+ names = fields.map {|field| field['name'] }
9
+ types = fields.map {|field| field['type'] }
9
10
  records = extract_records(jobs_query_response)
10
-
11
- page_token = jobs_query_response['pageToken']
12
11
  job_id = jobs_query_response['jobReference']['jobId']
13
- inherited_options = options.select {|k,v| [:maxResults, :timeoutMs].include?(k) }
12
+ page_token = jobs_query_response['pageToken']
13
+
14
14
  while page_token
15
- query_results_response = query_results(job_id, inherited_options.merge({ pageToken: page_token }))
15
+ query_results_response = query_results(job_id, { pageToken: page_token }.merge(options))
16
16
  records += extract_records(query_results_response)
17
17
  page_token = query_results_response['pageToken']
18
18
  end
@@ -3,7 +3,14 @@
3
3
  module BigQuery
4
4
  module Tables
5
5
  def tables(options = {})
6
- (list_tables(options)['tables'] || []).map {|t| t['tableReference']['tableId'] }
6
+ results = []
7
+ page_token = nil
8
+
9
+ loop do
10
+ response = list_tables({ pageToken: page_token }.merge(options))
11
+ results += (response['tables'] || []).map {|table| table['tableReference']['tableId'] }
12
+ return results unless (page_token = response['nextPageToken'])
13
+ end
7
14
  end
8
15
 
9
16
  def list_tables(options = {})
@@ -1,5 +1,5 @@
1
1
  module BigQuery
2
2
  class Client
3
- VERSION = '0.3.3'
3
+ VERSION = '0.3.4'
4
4
  end
5
5
  end
@@ -8,6 +8,16 @@ class TablesTest < Test::Unit::TestCase
8
8
  assert { $client.tables.include?(table_name) }
9
9
  end
10
10
 
11
+ def test_table_pagination
12
+ $client.tables.each {|t| $client.delete_table(t) }
13
+ 3.times do |i|
14
+ table_name = __method__.to_s + "_#{i.to_s}"
15
+ schema = [{ name: 'bar', type: 'string' }]
16
+ $client.create_table(table_name, schema)
17
+ end
18
+ assert { $client.tables(maxResults: 1).count == 3 }
19
+ end
20
+
11
21
  def test_fetch_schema
12
22
  table_name = __method__.to_s
13
23
  schema = [{ name: 'bar', type: 'string' }]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bigquery-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tsukuru Tanimichi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-19 00:00:00.000000000 Z
11
+ date: 2015-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-api-client
@@ -52,90 +52,6 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: test-unit
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: 3.0.0
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: 3.0.0
69
- - !ruby/object:Gem::Dependency
70
- name: dotenv
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: 1.0.0
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: 1.0.0
83
- - !ruby/object:Gem::Dependency
84
- name: awesome_print
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: pry
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: pry-doc
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: pry-byebug
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
55
  description:
140
56
  email:
141
57
  - ttanimichi@hotmail.com