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 +4 -4
- data/Gemfile +12 -0
- data/bigquery-client.gemspec +0 -6
- data/lib/bigquery-client/jobs.rb +6 -6
- data/lib/bigquery-client/tables.rb +8 -1
- data/lib/bigquery-client/version.rb +1 -1
- data/test/test_tables.rb +10 -0
- metadata +2 -86
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dcdf35c7bc17562e5cdd590bdbac3d6ae9df055d
|
4
|
+
data.tar.gz: 206728dd2bd10c4bda55ce79857e73b6c6f9d85b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a23eff48fd905f4de17ce835e2d7c7c3b85a8e31be65c23949b41640c846aa4061e1ecdb1b9661c83aba6e2e052323c41ac1117a39f87d1fa305b2bf676f6fd
|
7
|
+
data.tar.gz: c944d45ce22b57b5566b2218aa85baa4ca03e5541d8b10f6bcb9d50d5171a7c54e8d4b2afe40e649067996194f82fe2d6cfa812c5617dba989635c6ab4f35660
|
data/Gemfile
CHANGED
data/bigquery-client.gemspec
CHANGED
@@ -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
|
data/lib/bigquery-client/jobs.rb
CHANGED
@@ -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
|
-
|
8
|
-
|
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
|
-
|
12
|
+
page_token = jobs_query_response['pageToken']
|
13
|
+
|
14
14
|
while page_token
|
15
|
-
query_results_response = query_results(job_id,
|
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
|
-
|
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 = {})
|
data/test/test_tables.rb
CHANGED
@@ -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.
|
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-
|
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
|