presto-client 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +4 -6
- data/{ChangeLog → ChangeLog.md} +50 -84
- data/README.md +1 -1
- data/Rakefile +1 -3
- data/lib/presto/client/faraday_client.rb +3 -0
- data/lib/presto/client/statement_client.rb +4 -0
- data/lib/presto/client/version.rb +1 -1
- data/presto-client.gemspec +1 -1
- data/release.rb +58 -0
- data/spec/statement_client_spec.rb +41 -17
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a3dacca9fb546a0a9d8dc52d68c7fdaad0162dd79eba01a7f191da66b6c70fa5
|
4
|
+
data.tar.gz: 3440572020360608b0dab2ebfc5cf29e8de0482b5e4becbe48c6905078cd7161
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6776d64325948b52a4c7b99ba6b57022a1828ca1a225ba524f1d801cdfe70aa5362d936f8d430f6ffc349498ce84f0489b140f694c9510737f4890c5a3553e1
|
7
|
+
data.tar.gz: 841ddd0e1d0470a7451486fdb2809fc33b3d71ae620ed8d88d8d8a00ce6df998e1720692f4f67d61e1883e6be4695cac204c45434d0be80dfc295ef3fea34e7a
|
data/.travis.yml
CHANGED
data/{ChangeLog → ChangeLog.md}
RENAMED
@@ -1,41 +1,47 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
presto-client-ruby
|
2
|
+
====
|
3
|
+
## 0.6.2
|
4
|
+
- Release 0.6.2 [[68f5b27](https://github.com/treasure-data/presto-client-ruby/commit/68f5b27)]
|
5
|
+
- Merge pull request [#61](https://github.com/treasure-data/presto-client-ruby/issues/61) from treasure-data/implement_query_id [[6f3f236](https://github.com/treasure-data/presto-client-ruby/commit/6f3f236)]
|
6
|
+
- Merge pull request [#60](https://github.com/treasure-data/presto-client-ruby/issues/60) from treasure-data/fix_test [[01fa867](https://github.com/treasure-data/presto-client-ruby/commit/01fa867)]
|
7
|
+
- Merge pull request [#59](https://github.com/treasure-data/presto-client-ruby/issues/59) from treasure-data/update_readme [[50b2e2a](https://github.com/treasure-data/presto-client-ruby/commit/50b2e2a)]
|
8
|
+
- Update test target ruby versions [[2b65462](https://github.com/treasure-data/presto-client-ruby/commit/2b65462)]
|
9
|
+
- Update description of model_version [[750232e](https://github.com/treasure-data/presto-client-ruby/commit/750232e)]
|
10
|
+
- Remove old ruby versions [[28b1abb](https://github.com/treasure-data/presto-client-ruby/commit/28b1abb)]
|
11
|
+
- Enable fail_on_error [[9c1112a](https://github.com/treasure-data/presto-client-ruby/commit/9c1112a)]
|
12
|
+
- Fix tests which is only effective when presto version is less than 313 [[695966e](https://github.com/treasure-data/presto-client-ruby/commit/695966e)]
|
13
|
+
- Implement `StatementClient#query_id` [[2b692ca](https://github.com/treasure-data/presto-client-ruby/commit/2b692ca)]
|
14
|
+
- url encode properties ([#57](https://github.com/treasure-data/presto-client-ruby/issues/57)) [[8450627](https://github.com/treasure-data/presto-client-ruby/commit/8450627)]
|
15
|
+
|
16
|
+
|
17
|
+
## 0.6.1
|
3
18
|
* Fix WriterTarget 316 model class name
|
4
19
|
|
5
|
-
|
6
|
-
|
20
|
+
## 0.6.0
|
7
21
|
* Support presto 316 model class
|
8
22
|
|
9
|
-
|
10
|
-
2019-01-30 version 0.5.14
|
11
|
-
|
23
|
+
## 0.5.14
|
12
24
|
* Added `Query#current_results_headers` that returns HTTP response headers
|
13
25
|
|
14
|
-
|
15
|
-
|
26
|
+
## 0.5.13
|
16
27
|
* Added `query_timeout` and `plan_timeout` options with default disabled
|
17
28
|
* Changed timer to use CLOCK_MONOTONIC to avoid unexpected behavior when
|
18
29
|
system clock is updated
|
19
30
|
|
20
|
-
|
21
|
-
|
31
|
+
## 0.5.12
|
22
32
|
* Upgrade to Presto 0.205 model
|
23
33
|
|
24
|
-
|
25
|
-
|
34
|
+
## 0.5.11
|
26
35
|
* Support multiple session properties
|
27
36
|
* Check invalid JSON data response
|
28
37
|
|
29
|
-
|
30
|
-
|
38
|
+
## 0.5.10
|
31
39
|
* Added client_info, client_tags, and http_headers options.
|
32
40
|
|
33
|
-
|
34
|
-
|
41
|
+
## version 0.5.9
|
35
42
|
* Added error_name field at PrestoQueryError
|
36
43
|
|
37
|
-
|
38
|
-
|
44
|
+
## 0.5.8
|
39
45
|
* Added `Client#kill(query_id)` method.
|
40
46
|
* Added additional checking of internal exceptions so that client doesn't
|
41
47
|
silently return in case when Presto query is killed and Presto returns a
|
@@ -43,138 +49,98 @@
|
|
43
49
|
* Fixed `undefined local variable 'body'` error that was possibly happening
|
44
50
|
when Presto returned an unexpected data structure.
|
45
51
|
|
46
|
-
|
52
|
+
## 0.5.7
|
47
53
|
* Support a password option with HTTP basic auth
|
48
54
|
* Changed retry timeout from hard coded 2h to configurable default 2min
|
49
55
|
* Fix too deep nested json failure
|
50
56
|
|
51
|
-
|
57
|
+
## 0.5.6:
|
52
58
|
* Added missing inner class models for version 0.178
|
53
59
|
|
54
|
-
|
60
|
+
## 0.5.5:
|
55
61
|
* Added support for model version 0.178
|
56
62
|
|
57
|
-
|
58
|
-
|
63
|
+
## 0.5.4:
|
59
64
|
* Support "Content-Type: application/x-msgpack" for more efficient parsing of
|
60
65
|
HTTP response body.
|
61
66
|
* Added "enable_x_msgpack: true" option to send Accept header with
|
62
67
|
application/x-msgpack.
|
63
68
|
|
64
|
-
|
65
|
-
2017-04-26 version 0.5.3:
|
66
|
-
|
69
|
+
## 0.5.3:
|
67
70
|
* Added support for model version 0.173.
|
68
71
|
* Changed the default latest model version to 0.173.
|
69
72
|
* Fixed compatibility with the new major version of Farady
|
70
73
|
* Require Faraday 0.12 or later
|
71
74
|
|
72
|
-
|
73
|
-
2017-02-01 version 0.5.2:
|
74
|
-
|
75
|
+
## 0.5.2:
|
75
76
|
* Relax dependent version of Faraday to be able to use all 0.x versions.
|
76
77
|
* Fix build script that was broken due to new major version of rake.
|
77
78
|
|
78
|
-
|
79
|
-
2016-11-01 version 0.5.1:
|
80
|
-
|
79
|
+
## 0.5.1:
|
81
80
|
* Assume ConnectorId as a primitive type to be able to decode "connectorId"
|
82
81
|
fields.
|
83
82
|
|
84
|
-
|
85
|
-
2016-10-28 version 0.5.0:
|
86
|
-
|
83
|
+
## 0.5.0:
|
87
84
|
* Support multiple model versions
|
88
85
|
* Added support for model version 0.153.
|
89
86
|
* Changed the default latest model version to 0.513.
|
90
87
|
|
91
|
-
|
92
|
-
2016-08-09 version 0.4.17:
|
93
|
-
|
88
|
+
## 0.4.17:
|
94
89
|
* Added support for :ssl option.
|
95
90
|
|
96
|
-
|
97
|
-
2016-08-03 version 0.4.16:
|
98
|
-
|
91
|
+
## 0.4.16:
|
99
92
|
* Upgraded Presto model version to 0.151
|
100
93
|
|
101
|
-
|
102
|
-
2016-08-03 version 0.4.15:
|
103
|
-
|
94
|
+
## 0.4.15:
|
104
95
|
* decode method of model classes validate Hash type
|
105
96
|
|
106
|
-
|
107
|
-
2016-08-02 version 0.4.14:
|
108
|
-
|
97
|
+
## 0.4.14:
|
109
98
|
* Added support for resuming fetching query results by using new `Query.resume(next_uri, options)` method (@tetrakai++)
|
110
99
|
|
111
|
-
|
112
|
-
2016-08-02 version 0.4.13:
|
113
|
-
|
100
|
+
## 0.4.13:
|
114
101
|
* Added support for :http_proxy option to use a HTTP proxy server
|
115
102
|
* Added support for hashed Client response using `run_with_names` (thanks to MoovWeb for allowing me to contribute)
|
116
103
|
* Upgraded Presto model version to 0.134
|
117
104
|
|
118
|
-
|
119
|
-
|
105
|
+
## 0.4.5:
|
120
106
|
* Upgraded Presto model version to 0.99
|
121
107
|
|
122
|
-
|
123
|
-
2014-11-20 version 0.4.3:
|
124
|
-
|
108
|
+
## 0.4.3:
|
125
109
|
* Updated gem dependency to accept faraday ~> 0.9.x as well as ~> 0.8.8
|
126
110
|
|
127
|
-
|
128
|
-
2014-10-15 version 0.4.2:
|
129
|
-
|
111
|
+
## 0.4.2:
|
130
112
|
* Added support for :properties option to set session properties introduced
|
131
113
|
since Presto 0.78
|
132
114
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
* Added EquiJoinClause model class
|
115
|
+
## 0.4.1:
|
116
|
+
Added EquiJoinClause model class
|
137
117
|
* Added StageId#query_id and #id methods
|
138
118
|
* Added TaskId#query_id, #stage_id and #id methods
|
139
119
|
|
140
|
-
|
141
|
-
2014-06-10 version 0.4.0:
|
142
|
-
|
120
|
+
## 0.4.0:
|
143
121
|
* Added Query#current_results, #advance and #query_info for advanced users
|
144
122
|
* Generate model classes from Presto source code to include complete classes
|
145
123
|
|
146
|
-
|
147
|
-
2014-05-06 version 0.3.3:
|
148
|
-
|
124
|
+
## 0.3.3:
|
149
125
|
* Added :time_zone and :language options added by Presto 0.66
|
150
126
|
|
151
|
-
|
152
|
-
2014-04-01 version 0.3.2:
|
153
|
-
|
127
|
+
## 0.3.2:
|
154
128
|
* Fixed a problem that client skips the last chunk if result is large
|
155
129
|
|
156
|
-
|
157
|
-
2014-01-30 version 0.3.1:
|
158
|
-
|
130
|
+
## 0.3.1:
|
159
131
|
* Added http_debug option
|
160
132
|
* Disabled HTTP debug logging by default
|
161
133
|
|
162
|
-
|
163
|
-
2014-01-22 version 0.3.0:
|
164
|
-
|
134
|
+
## 0.3.0:
|
165
135
|
* Added http_timeout option
|
166
136
|
* Added http_open_timeout option
|
167
137
|
* Changed Query.start API to start(query, options) to http options
|
168
138
|
|
169
|
-
|
170
|
-
2014-01-22 version 0.2.0:
|
171
|
-
|
139
|
+
## 0.2.0:
|
172
140
|
* Added Query#cancel
|
173
141
|
* Added Query#close
|
174
142
|
* Added Client#run
|
175
143
|
* Changed required_ruby_version from 1.9.3 to 1.9.1
|
176
144
|
|
177
|
-
|
178
|
-
2014-01-07 version 0.1.0:
|
179
|
-
|
145
|
+
## 0.1.0:
|
180
146
|
* First release
|
data/README.md
CHANGED
@@ -101,7 +101,7 @@ $ bundle exec rake modelgen:latest
|
|
101
101
|
* **http_debug** enables debug message to STDOUT for each HTTP requests.
|
102
102
|
* **http_open_timeout** sets timeout in seconds to open new HTTP connection.
|
103
103
|
* **http_timeout** sets timeout in seconds to read data from a server.
|
104
|
-
* **model_version** set the presto version to which a job is submitted. Supported versions are 0.205, 0.178, 0.173, 0.153 and 0.149. Default is
|
104
|
+
* **model_version** set the presto version to which a job is submitted. Supported versions are 316, 303, 0.205, 0.178, 0.173, 0.153 and 0.149. Default is 316.
|
105
105
|
|
106
106
|
See [RDoc](http://www.rubydoc.info/gems/presto-client/) for the full documentation.
|
107
107
|
|
data/Rakefile
CHANGED
@@ -15,6 +15,8 @@
|
|
15
15
|
#
|
16
16
|
module Presto::Client
|
17
17
|
|
18
|
+
require 'cgi'
|
19
|
+
|
18
20
|
module PrestoHeaders
|
19
21
|
PRESTO_USER = "X-Presto-User"
|
20
22
|
PRESTO_SOURCE = "X-Presto-Source"
|
@@ -155,6 +157,7 @@ module Presto::Client
|
|
155
157
|
if field_value =~ HTTP11_CTL_CHARSET_REGEXP
|
156
158
|
raise Faraday::ClientError, "Value of properties can't include HTTP/1.1 control characters"
|
157
159
|
end
|
160
|
+
field_value = CGI.escape(field_value)
|
158
161
|
"#{token}=#{field_value}"
|
159
162
|
end
|
160
163
|
end
|
data/presto-client.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |gem|
|
|
9
9
|
gem.description = %q{Presto client library}
|
10
10
|
gem.summary = %q{Presto client library}
|
11
11
|
gem.homepage = "https://github.com/treasure-data/presto-client-ruby"
|
12
|
-
gem.license = "Apache
|
12
|
+
gem.license = "Apache-2.0"
|
13
13
|
|
14
14
|
gem.files = `git ls-files`.split($\)
|
15
15
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
data/release.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
PREFIX = 'https://github.com/treasure-data/presto-client-ruby'
|
6
|
+
RELEASE_NOTES_FILE = "ChangeLog.md"
|
7
|
+
|
8
|
+
last_tag = `git describe --tags --abbrev=0`.chomp
|
9
|
+
last_version = last_tag.sub("v", "")
|
10
|
+
puts "last version: #{last_version}"
|
11
|
+
|
12
|
+
print "next version? "
|
13
|
+
next_version = STDIN.gets.chomp
|
14
|
+
|
15
|
+
abort("Can't use empty version string") if next_version.empty?
|
16
|
+
|
17
|
+
logs = `git log #{last_tag}..HEAD --pretty=format:'%h %s'`
|
18
|
+
# Add links to GitHub issues
|
19
|
+
logs = logs.gsub(/\#([0-9]+)/, "[#\\1](#{PREFIX}/issues/\\1)")
|
20
|
+
# Add links to JIRA tickets (e.g,. MPP-xxxx, PLT-xxxx)
|
21
|
+
logs = logs.gsub(/^([A-Z]{2,}+-[0-9]+):/, '[\1](https://treasure-data.atlassian.net/browse/\1):')
|
22
|
+
|
23
|
+
new_release_notes = []
|
24
|
+
new_release_notes <<= "\#\# #{next_version}\n"
|
25
|
+
new_release_notes <<= logs.split(/\n/)
|
26
|
+
.reject{|line| line.include?("#{last_version} release notes")}
|
27
|
+
.map{|x|
|
28
|
+
rev = x[0..6]
|
29
|
+
"- #{x[8..-1]} [[#{rev}](#{PREFIX}/commit/#{rev})]\n"
|
30
|
+
}
|
31
|
+
|
32
|
+
release_notes = []
|
33
|
+
notes = File.readlines(RELEASE_NOTES_FILE)
|
34
|
+
|
35
|
+
release_notes <<= notes[0..1]
|
36
|
+
release_notes <<= new_release_notes
|
37
|
+
release_notes <<= "\n"
|
38
|
+
release_notes <<= notes[2..-1]
|
39
|
+
|
40
|
+
TMP_RELEASE_NOTES_FILE = "#{RELEASE_NOTES_FILE}.tmp"
|
41
|
+
File.delete(TMP_RELEASE_NOTES_FILE) if File.exists?(TMP_RELEASE_NOTES_FILE)
|
42
|
+
File.write("#{TMP_RELEASE_NOTES_FILE}", release_notes.join)
|
43
|
+
system("cat #{TMP_RELEASE_NOTES_FILE} | vim - -c ':f #{TMP_RELEASE_NOTES_FILE}' -c ':9'")
|
44
|
+
|
45
|
+
abort("The release note file is not saved. Aborted") unless File.exists?(TMP_RELEASE_NOTES_FILE)
|
46
|
+
|
47
|
+
def run(cmd)
|
48
|
+
puts cmd
|
49
|
+
system cmd
|
50
|
+
end
|
51
|
+
|
52
|
+
FileUtils.cp(TMP_RELEASE_NOTES_FILE, RELEASE_NOTES_FILE)
|
53
|
+
File.delete(TMP_RELEASE_NOTES_FILE)
|
54
|
+
|
55
|
+
# run "git commit #{RELEASE_NOTES_FILE} -m \"Add #{next_version} release notes\""
|
56
|
+
# run "git tag v#{next_version}"
|
57
|
+
# run "git push"
|
58
|
+
# run "git push --tags"
|
@@ -112,24 +112,32 @@ describe Presto::Client::StatementClient do
|
|
112
112
|
retry_p.should be_true
|
113
113
|
end
|
114
114
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
lambda do
|
129
|
-
Models::DeleteHandle.decode({
|
130
|
-
"handle" => "invalid"
|
115
|
+
# presto version could be "V0_ddd" or "Vddd"
|
116
|
+
/\APresto::Client::ModelVersions::V(\w+)/ =~ Presto::Client::Models.to_s
|
117
|
+
|
118
|
+
# https://github.com/prestosql/presto/commit/80a2c5113d47e3390bf6dc041486a1c9dfc04592
|
119
|
+
# renamed DeleteHandle to DeleteTarget, then DeleteHandle exists when presto version
|
120
|
+
# is less than 313.
|
121
|
+
if $1[0, 2] == "0_" || $1.to_i < 314
|
122
|
+
it "decodes DeleteHandle" do
|
123
|
+
dh = Models::DeleteHandle.decode({
|
124
|
+
"handle" => {
|
125
|
+
"connectorId" => "c1",
|
126
|
+
"connectorHandle" => {}
|
127
|
+
}
|
131
128
|
})
|
132
|
-
|
129
|
+
dh.handle.should be_a_kind_of Models::TableHandle
|
130
|
+
dh.handle.connector_id.should == "c1"
|
131
|
+
dh.handle.connector_handle.should == {}
|
132
|
+
end
|
133
|
+
|
134
|
+
it "validates models" do
|
135
|
+
lambda do
|
136
|
+
Models::DeleteHandle.decode({
|
137
|
+
"handle" => "invalid"
|
138
|
+
})
|
139
|
+
end.should raise_error(TypeError, /String to Hash/)
|
140
|
+
end
|
133
141
|
end
|
134
142
|
|
135
143
|
it "receives headers of POST" do
|
@@ -148,6 +156,22 @@ describe Presto::Client::StatementClient do
|
|
148
156
|
q.current_results_headers["X-Test-Header"].should == "123"
|
149
157
|
end
|
150
158
|
|
159
|
+
describe "#query_id" do
|
160
|
+
it "returns query_id" do
|
161
|
+
stub_request(:post, "localhost/v1/statement").
|
162
|
+
with(body: query).to_return(body: response_json2.to_json, headers: {"X-Test-Header" => "123"})
|
163
|
+
|
164
|
+
stub_request(:get, "localhost/v1/next_uri").
|
165
|
+
to_return(body: response_json.to_json, headers: {"X-Test-Header" => "123"})
|
166
|
+
|
167
|
+
sc = StatementClient.new(faraday, query, options.merge(http_open_timeout: 1))
|
168
|
+
sc.query_id.should == "queryid"
|
169
|
+
sc.has_next?.should be_true
|
170
|
+
sc.advance.should be_true
|
171
|
+
sc.query_id.should == "queryid"
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
151
175
|
describe '#query_info' do
|
152
176
|
let :headers do
|
153
177
|
{
|
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.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sadayuki Furuhashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -123,7 +123,7 @@ extra_rdoc_files: []
|
|
123
123
|
files:
|
124
124
|
- ".gitignore"
|
125
125
|
- ".travis.yml"
|
126
|
-
- ChangeLog
|
126
|
+
- ChangeLog.md
|
127
127
|
- Gemfile
|
128
128
|
- README.md
|
129
129
|
- Rakefile
|
@@ -148,13 +148,14 @@ files:
|
|
148
148
|
- modelgen/models.rb
|
149
149
|
- modelgen/presto_models.rb
|
150
150
|
- presto-client.gemspec
|
151
|
+
- release.rb
|
151
152
|
- spec/client_spec.rb
|
152
153
|
- spec/model_spec.rb
|
153
154
|
- spec/spec_helper.rb
|
154
155
|
- spec/statement_client_spec.rb
|
155
156
|
homepage: https://github.com/treasure-data/presto-client-ruby
|
156
157
|
licenses:
|
157
|
-
- Apache
|
158
|
+
- Apache-2.0
|
158
159
|
metadata: {}
|
159
160
|
post_install_message:
|
160
161
|
rdoc_options: []
|
@@ -172,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
172
173
|
version: '0'
|
173
174
|
requirements: []
|
174
175
|
rubyforge_project:
|
175
|
-
rubygems_version: 2.
|
176
|
+
rubygems_version: 2.7.6
|
176
177
|
signing_key:
|
177
178
|
specification_version: 4
|
178
179
|
summary: Presto client library
|