presto-client 0.5.10 → 0.5.11
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 +5 -5
- data/ChangeLog +5 -0
- data/lib/presto/client/faraday_client.rb +1 -2
- data/lib/presto/client/statement_client.rb +10 -5
- data/lib/presto/client/version.rb +1 -1
- data/spec/statement_client_spec.rb +21 -10
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8057cfffdbe9a99760500827e16e2acfa2226c8fe70c7a20ce3fe4708ed80c02
|
4
|
+
data.tar.gz: 7655979e2fc05d9805c0ea704fba1b37c029a5051c2d4eb3a5d5f2d0d1f392ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 554e580324ff6bcf0cb0a5d38360147ac731e1abe0a93390ce3a8a8c2de6683d6e0365ec14022d6a888e44abcafb7eb4756a8a7bf2f45f0f9baf62c6c7bbf616
|
7
|
+
data.tar.gz: 5b647ad42f45cbb703c6d4ac5dc7ae0bc7ba6f6f36eea5826d7659b7fb704cee11dc562f3fb1eed47b0f4ce3a1a586b8ee7ddd43ae979b259b7ee9d3829af9de
|
data/ChangeLog
CHANGED
@@ -146,7 +146,6 @@ module Presto::Client
|
|
146
146
|
HTTP11_CTL_CHARSET_REGEXP = /[#{Regexp.escape(HTTP11_CTL_CHARSET.join)}]/
|
147
147
|
|
148
148
|
def self.encode_properties(properties)
|
149
|
-
# this is a hack to set same header multiple times.
|
150
149
|
properties.map do |k, v|
|
151
150
|
token = k.to_s
|
152
151
|
field_value = v.to_s # TODO LWS encoding is not implemented
|
@@ -157,7 +156,7 @@ module Presto::Client
|
|
157
156
|
raise Faraday::ClientError, "Value of properties can't include HTTP/1.1 control characters"
|
158
157
|
end
|
159
158
|
"#{token}=#{field_value}"
|
160
|
-
end
|
159
|
+
end
|
161
160
|
end
|
162
161
|
|
163
162
|
def self.encode_client_info(info)
|
@@ -140,11 +140,16 @@ module Presto::Client
|
|
140
140
|
private :decode_model
|
141
141
|
|
142
142
|
def parse_body(response)
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
143
|
+
begin
|
144
|
+
case response.headers['Content-Type']
|
145
|
+
when 'application/x-msgpack'
|
146
|
+
MessagePack.load(response.body)
|
147
|
+
else
|
148
|
+
JSON.parse(response.body, opts = JSON_OPTIONS)
|
149
|
+
end
|
150
|
+
rescue => e
|
151
|
+
@exception = PrestoHttpError.new(500, "Presto API returned unexpected data format. #{e}")
|
152
|
+
raise @exception
|
148
153
|
end
|
149
154
|
end
|
150
155
|
|
@@ -133,8 +133,8 @@ describe Presto::Client::StatementClient do
|
|
133
133
|
end
|
134
134
|
|
135
135
|
describe '#query_info' do
|
136
|
-
|
137
|
-
|
136
|
+
let :headers do
|
137
|
+
{
|
138
138
|
"User-Agent" => "presto-ruby/#{VERSION}",
|
139
139
|
"X-Presto-Catalog" => options[:catalog],
|
140
140
|
"X-Presto-Schema" => options[:schema],
|
@@ -142,21 +142,32 @@ describe Presto::Client::StatementClient do
|
|
142
142
|
"X-Presto-Language" => options[:language],
|
143
143
|
"X-Presto-Time-Zone" => options[:time_zone],
|
144
144
|
}
|
145
|
+
end
|
145
146
|
|
147
|
+
let :statement_client do
|
146
148
|
stub_request(:post, "http://localhost/v1/statement").
|
147
149
|
with(body: query, headers: headers).
|
148
150
|
to_return(body: response_json2.to_json)
|
151
|
+
StatementClient.new(faraday, query, options)
|
152
|
+
end
|
149
153
|
|
150
|
-
|
151
|
-
|
152
|
-
stub_request(:get, "http://localhost/v1/query/#{response_json2[:id]}").
|
153
|
-
with(headers: headers).
|
154
|
-
to_return(body: {"session" => "invalid session structure"}.to_json)
|
155
|
-
|
154
|
+
it "raises an exception with sample JSON if response is unexpected" do
|
156
155
|
lambda do
|
157
|
-
|
156
|
+
stub_request(:get, "http://localhost/v1/query/#{response_json2[:id]}").
|
157
|
+
with(headers: headers).
|
158
|
+
to_return(body: {"session" => "invalid session structure"}.to_json)
|
159
|
+
statement_client.query_info
|
158
160
|
end.should raise_error(PrestoHttpError, /Presto API returned unexpected structure at \/v1\/query\/queryid\. Expected Presto::Client::ModelVersions::.*::QueryInfo but got {"session":"invalid session structure"}/)
|
159
161
|
end
|
162
|
+
|
163
|
+
it "raises an exception if response format is unexpected" do
|
164
|
+
lambda do
|
165
|
+
stub_request(:get, "http://localhost/v1/query/#{response_json2[:id]}").
|
166
|
+
with(headers: headers).
|
167
|
+
to_return(body: "unexpected data structure (not JSON)")
|
168
|
+
statement_client.query_info
|
169
|
+
end.should raise_error(PrestoHttpError, /Presto API returned unexpected data format./)
|
170
|
+
end
|
160
171
|
end
|
161
172
|
|
162
173
|
describe "Killing a query" do
|
@@ -196,7 +207,7 @@ describe Presto::Client::StatementClient do
|
|
196
207
|
stub_request(:post, "localhost/v1/statement").
|
197
208
|
with(body: query,
|
198
209
|
headers: headers.merge({
|
199
|
-
"X-Presto-Session" => options[:properties].map {|k,v| "#{k}=#{v}"}.join("
|
210
|
+
"X-Presto-Session" => options[:properties].map {|k,v| "#{k}=#{v}"}.join(", ")
|
200
211
|
})).
|
201
212
|
to_return(body: response_json.to_json)
|
202
213
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: presto-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sadayuki Furuhashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -169,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
169
169
|
version: '0'
|
170
170
|
requirements: []
|
171
171
|
rubyforge_project:
|
172
|
-
rubygems_version: 2.6
|
172
|
+
rubygems_version: 2.7.6
|
173
173
|
signing_key:
|
174
174
|
specification_version: 4
|
175
175
|
summary: Presto client library
|