bigquery 0.7.0 → 0.8.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 +4 -0
- data/Gemfile.lock +20 -7
- data/lib/big_query/client.rb +5 -1
- data/lib/big_query/client/jobs.rb +7 -3
- data/lib/big_query/client/query.rb +12 -4
- data/lib/big_query/version.rb +1 -1
- data/test/bigquery.rb +13 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4801bae739335efd291f0b1bc7f40c24774d28ad
|
4
|
+
data.tar.gz: 7fc58959d20e1b2320fe668fa98ae2b19bda2a19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 676d0d4c40351e00a645f68e37c0cfdc4b075beab86c74b31bf8717df3d9240a30973ca3b1fc7ccc8fe9b29088675b507d09e46a09a195131582f61905d73ccc
|
7
|
+
data.tar.gz: 0900f97212217ceecd258db6df7d0f4b365d5ab291bd0c19e3049355378b9266ca2c427bbabaaa8ee3b0d60df768ca847c6b197a9e391459a68be7d9677b30c3
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bigquery (0.
|
4
|
+
bigquery (0.8.0)
|
5
5
|
google-api-client (~> 0.8.2)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activesupport (4.2.
|
10
|
+
activesupport (4.2.1)
|
11
11
|
i18n (~> 0.7)
|
12
12
|
json (~> 1.7, >= 1.7.7)
|
13
13
|
minitest (~> 5.1)
|
14
14
|
thread_safe (~> 0.3, >= 0.3.4)
|
15
15
|
tzinfo (~> 1.1)
|
16
|
-
addressable (2.3.
|
16
|
+
addressable (2.3.8)
|
17
17
|
autoparse (0.3.3)
|
18
18
|
addressable (>= 2.3.1)
|
19
19
|
extlib (>= 0.9.15)
|
@@ -27,24 +27,37 @@ GEM
|
|
27
27
|
extlib (0.9.16)
|
28
28
|
faraday (0.9.1)
|
29
29
|
multipart-post (>= 1.2, < 3)
|
30
|
-
google-api-client (0.8.
|
30
|
+
google-api-client (0.8.6)
|
31
31
|
activesupport (>= 3.2)
|
32
32
|
addressable (~> 2.3)
|
33
33
|
autoparse (~> 0.3)
|
34
34
|
extlib (~> 0.9)
|
35
35
|
faraday (~> 0.9)
|
36
|
+
googleauth (~> 0.3)
|
36
37
|
launchy (~> 2.4)
|
37
38
|
multi_json (~> 1.10)
|
38
39
|
retriable (~> 1.4)
|
39
40
|
signet (~> 0.6)
|
41
|
+
googleauth (0.4.1)
|
42
|
+
faraday (~> 0.9)
|
43
|
+
jwt (~> 1.4)
|
44
|
+
logging (~> 2.0)
|
45
|
+
memoist (~> 0.12)
|
46
|
+
multi_json (= 1.11)
|
47
|
+
signet (~> 0.6)
|
40
48
|
i18n (0.7.0)
|
41
49
|
json (1.8.2)
|
42
|
-
jwt (1.
|
50
|
+
jwt (1.5.0)
|
43
51
|
launchy (2.4.3)
|
44
52
|
addressable (~> 2.3)
|
53
|
+
little-plugger (1.1.3)
|
54
|
+
logging (2.0.0)
|
55
|
+
little-plugger (~> 1.1)
|
56
|
+
multi_json (~> 1.10)
|
57
|
+
memoist (0.12.0)
|
45
58
|
method_source (0.8.2)
|
46
59
|
minitest (5.3.4)
|
47
|
-
multi_json (1.
|
60
|
+
multi_json (1.11.0)
|
48
61
|
multipart-post (2.0.0)
|
49
62
|
pry (0.9.12.6)
|
50
63
|
coderay (~> 1.0)
|
@@ -62,7 +75,7 @@ GEM
|
|
62
75
|
jwt (~> 1.0)
|
63
76
|
multi_json (~> 1.10)
|
64
77
|
slop (3.5.0)
|
65
|
-
thread_safe (0.3.
|
78
|
+
thread_safe (0.3.5)
|
66
79
|
tzinfo (1.2.2)
|
67
80
|
thread_safe (~> 0.1)
|
68
81
|
|
data/lib/big_query/client.rb
CHANGED
@@ -21,7 +21,11 @@ module BigQuery
|
|
21
21
|
faraday_option: opts['faraday_option']
|
22
22
|
)
|
23
23
|
|
24
|
-
|
24
|
+
begin
|
25
|
+
key = Google::APIClient::KeyUtils.load_from_pkcs12(opts['key'], 'notasecret')
|
26
|
+
rescue ArgumentError
|
27
|
+
key = Google::APIClient::KeyUtils.load_from_pem(opts['key'], 'notasecret')
|
28
|
+
end
|
25
29
|
|
26
30
|
@client.authorization = Signet::OAuth2::Client.new(
|
27
31
|
token_credential_uri: 'https://accounts.google.com/o/oauth2/token',
|
@@ -38,11 +38,15 @@ module BigQuery
|
|
38
38
|
|
39
39
|
# Insert a job
|
40
40
|
#
|
41
|
-
# @param options [Hash] hash of job options
|
41
|
+
# @param options [Hash] hash of job options
|
42
|
+
# @param parameters [Hash] hash of parameters (uploadType, etc.)
|
43
|
+
# @param media [Google::APIClient::UploadIO] media upload
|
42
44
|
# @return [Hash] json api response
|
43
|
-
def insert_job(opts)
|
45
|
+
def insert_job(opts, parameters = {}, media = nil)
|
44
46
|
api(api_method: @bq.jobs.insert,
|
45
|
-
|
47
|
+
parameters: parameters,
|
48
|
+
body_object: {configuration: opts},
|
49
|
+
media: media)
|
46
50
|
end
|
47
51
|
end
|
48
52
|
end
|
@@ -5,14 +5,22 @@ module BigQuery
|
|
5
5
|
#
|
6
6
|
# @param given_query [String] query to perform
|
7
7
|
# @param options [Hash] query options
|
8
|
-
# @option options [Integer] timeout (90 * 1000) timeout in miliseconds
|
8
|
+
# @option options [Integer] timeout or timeoutMs (90 * 1000) timeout in miliseconds
|
9
|
+
# @option options [Boolean] dryRun Don't actually run this job
|
10
|
+
# @option options [Integer] maxResults The maximum number of rows of data to return per page of results.
|
11
|
+
# @option options [Boolean] useQueryCache Whether to look for the result in the query cache.
|
9
12
|
# @return [Hash] json api response
|
13
|
+
# @see https://cloud.google.com/bigquery/docs/reference/v2/jobs/query
|
10
14
|
def query(given_query, options={})
|
11
|
-
|
15
|
+
body_object = { 'query' => given_query }
|
16
|
+
body_object['timeoutMs'] = options[:timeout] || options[:timeoutMs] || 90 * 1000
|
17
|
+
body_object['maxResults'] = options[:maxResults] if options[:maxResults]
|
18
|
+
body_object['dryRun'] = options[:dryRun] if options.has_key?(:dryRun)
|
19
|
+
body_object['useQueryCache'] = options[:useQueryCache] if options.has_key?(:useQueryCache)
|
20
|
+
|
12
21
|
response = api(
|
13
22
|
api_method: @bq.jobs.query,
|
14
|
-
body_object:
|
15
|
-
'timeoutMs' => timeout}
|
23
|
+
body_object: body_object,
|
16
24
|
)
|
17
25
|
|
18
26
|
response
|
data/lib/big_query/version.rb
CHANGED
data/test/bigquery.rb
CHANGED
@@ -120,6 +120,19 @@ class BigQueryTest < MiniTest::Unit::TestCase
|
|
120
120
|
assert_equal result['jobComplete'], true
|
121
121
|
end
|
122
122
|
|
123
|
+
def test_for_query_useQueryCache
|
124
|
+
result = @bq.query("SELECT * FROM [#{config['dataset']}.test] LIMIT 1", useQueryCache: true)
|
125
|
+
result = @bq.query("SELECT * FROM [#{config['dataset']}.test] LIMIT 1", useQueryCache: true)
|
126
|
+
|
127
|
+
assert_equal result['cacheHit'], true
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_for_query_dryRun
|
131
|
+
result = @bq.query("SELECT * FROM [#{config['dataset']}.test] LIMIT 1", dryRun: true)
|
132
|
+
|
133
|
+
assert_equal result['jobReference']['jobId'], nil
|
134
|
+
end
|
135
|
+
|
123
136
|
def test_for_insert
|
124
137
|
result = @bq.insert('test' ,"id" => 123, "type" => "Task")
|
125
138
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bigquery
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Bronte
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-06-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: google-api-client
|
@@ -127,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
127
|
version: '0'
|
128
128
|
requirements: []
|
129
129
|
rubyforge_project:
|
130
|
-
rubygems_version: 2.4.
|
130
|
+
rubygems_version: 2.4.6
|
131
131
|
signing_key:
|
132
132
|
specification_version: 4
|
133
133
|
summary: A nice wrapper for Google Big Query
|