trino-client 1.0.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/CODEOWNERS +1 -1
- data/.github/dependabot.yaml +10 -0
- data/.github/release-drafter.yml +45 -0
- data/.github/workflows/codeql-analysis.yml +71 -0
- data/.github/workflows/release-drafter.yml +29 -0
- data/.github/workflows/ruby.yml +23 -14
- data/.standard.yml +15 -0
- data/.standard_todo.yml +80 -0
- data/ChangeLog.md +39 -0
- data/Gemfile +3 -2
- data/Rakefile +8 -9
- data/lib/trino/client/faraday_client.rb +12 -4
- data/lib/trino/client/query.rb +5 -3
- data/lib/trino/client/statement_client.rb +4 -2
- data/lib/trino/client/version.rb +1 -1
- data/lib/trino/client.rb +2 -4
- data/lib/trino-client.rb +1 -1
- data/modelgen/modelgen.rb +3 -5
- data/modelgen/trino_models.rb +18 -20
- data/publish.rb +1 -2
- data/release.rb +10 -10
- data/spec/basic_query_spec.rb +1 -1
- data/spec/client_spec.rb +16 -16
- data/spec/gzip_spec.rb +1 -1
- data/spec/model_spec.rb +5 -3
- data/spec/spec_helper.rb +3 -2
- data/spec/statement_client_spec.rb +120 -123
- data/spec/tpch_query_spec.rb +1 -1
- data/trino-client-ruby/lib/trino-client-ruby.rb +1 -1
- data/trino-client-ruby/trino-client-ruby.gemspec +4 -4
- data/trino-client.gemspec +15 -13
- metadata +81 -36
@@ -32,14 +32,14 @@ describe Trino::Client::StatementClient do
|
|
32
32
|
it "sets headers" do
|
33
33
|
stub_request(:post, "localhost/v1/statement").
|
34
34
|
with(body: query,
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
35
|
+
headers: {
|
36
|
+
"User-Agent" => "trino-ruby/#{VERSION}",
|
37
|
+
"X-Trino-Catalog" => options[:catalog],
|
38
|
+
"X-Trino-Schema" => options[:schema],
|
39
|
+
"X-Trino-User" => options[:user],
|
40
|
+
"X-Trino-Language" => options[:language],
|
41
|
+
"X-Trino-Time-Zone" => options[:time_zone],
|
42
|
+
}).to_return(body: response_json.to_json)
|
43
43
|
|
44
44
|
StatementClient.new(faraday, query, options)
|
45
45
|
end
|
@@ -56,14 +56,14 @@ describe Trino::Client::StatementClient do
|
|
56
56
|
retry_p = false
|
57
57
|
stub_request(:post, "localhost/v1/statement").
|
58
58
|
with(body: query,
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
59
|
+
headers: {
|
60
|
+
"User-Agent" => "trino-ruby/#{VERSION}",
|
61
|
+
"X-Trino-Catalog" => options[:catalog],
|
62
|
+
"X-Trino-Schema" => options[:schema],
|
63
|
+
"X-Trino-User" => options[:user],
|
64
|
+
"X-Trino-Language" => options[:language],
|
65
|
+
"X-Trino-Time-Zone" => options[:time_zone],
|
66
|
+
}).to_return(body: response_json2.to_json)
|
67
67
|
|
68
68
|
stub_request(:get, "localhost/v1/next_uri").
|
69
69
|
with(headers: {
|
@@ -73,27 +73,27 @@ describe Trino::Client::StatementClient do
|
|
73
73
|
"X-Trino-User" => options[:user],
|
74
74
|
"X-Trino-Language" => options[:language],
|
75
75
|
"X-Trino-Time-Zone" => options[:time_zone],
|
76
|
-
}).to_return(body: lambda{|req|if retry_p; response_json.to_json; else; retry_p=true; raise Timeout::Error.new("execution expired"); end })
|
76
|
+
}).to_return(body: lambda { |req| if retry_p; response_json.to_json; else; retry_p = true; raise Timeout::Error.new("execution expired"); end })
|
77
77
|
|
78
78
|
sc = StatementClient.new(faraday, query, options.merge(http_open_timeout: 1))
|
79
|
-
sc.has_next
|
80
|
-
sc.advance.
|
81
|
-
retry_p.
|
79
|
+
expect(sc.has_next?).to eq true
|
80
|
+
expect(sc.advance).to eq true
|
81
|
+
expect(retry_p).to eq true
|
82
82
|
end
|
83
83
|
|
84
84
|
it "uses 'Accept: application/x-msgpack' if option is set" do
|
85
85
|
retry_p = false
|
86
86
|
stub_request(:post, "localhost/v1/statement").
|
87
87
|
with(body: query,
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
88
|
+
headers: {
|
89
|
+
"User-Agent" => "trino-ruby/#{VERSION}",
|
90
|
+
"X-Trino-Catalog" => options[:catalog],
|
91
|
+
"X-Trino-Schema" => options[:schema],
|
92
|
+
"X-Trino-User" => options[:user],
|
93
|
+
"X-Trino-Language" => options[:language],
|
94
|
+
"X-Trino-Time-Zone" => options[:time_zone],
|
95
|
+
"Accept" => "application/x-msgpack,application/json"
|
96
|
+
}).to_return(body: MessagePack.dump(response_json2), headers: {"Content-Type" => "application/x-msgpack"})
|
97
97
|
|
98
98
|
stub_request(:get, "localhost/v1/next_uri").
|
99
99
|
with(headers: {
|
@@ -104,13 +104,13 @@ describe Trino::Client::StatementClient do
|
|
104
104
|
"X-Trino-Language" => options[:language],
|
105
105
|
"X-Trino-Time-Zone" => options[:time_zone],
|
106
106
|
"Accept" => "application/x-msgpack,application/json"
|
107
|
-
}).to_return(body: lambda{|req|if retry_p; MessagePack.dump(response_json); else; retry_p=true; raise Timeout::Error.new("execution expired"); end }, headers: {"Content-Type" => "application/x-msgpack"})
|
107
|
+
}).to_return(body: lambda { |req| if retry_p; MessagePack.dump(response_json); else; retry_p = true; raise Timeout::Error.new("execution expired"); end }, headers: {"Content-Type" => "application/x-msgpack"})
|
108
108
|
|
109
109
|
options.merge!(http_open_timeout: 1, enable_x_msgpack: "application/x-msgpack")
|
110
110
|
sc = StatementClient.new(faraday, query, options)
|
111
|
-
sc.has_next
|
112
|
-
sc.advance.
|
113
|
-
retry_p.
|
111
|
+
expect(sc.has_next?).to eq true
|
112
|
+
expect(sc.advance).to eq true
|
113
|
+
expect(retry_p).to eq true
|
114
114
|
end
|
115
115
|
|
116
116
|
# trino version could be "V0_ddd" or "Vddd"
|
@@ -127,17 +127,17 @@ describe Trino::Client::StatementClient do
|
|
127
127
|
"connectorHandle" => {}
|
128
128
|
}
|
129
129
|
})
|
130
|
-
dh.handle.
|
131
|
-
dh.handle.connector_id.
|
132
|
-
dh.handle.connector_handle.
|
130
|
+
expect(dh.handle).to be_a_kind_of Models::TableHandle
|
131
|
+
expect(dh.handle.connector_id).to eq "c1"
|
132
|
+
expect(dh.handle.connector_handle).to eq {}
|
133
133
|
end
|
134
134
|
|
135
135
|
it "validates models" do
|
136
|
-
|
136
|
+
expect do
|
137
137
|
Models::DeleteHandle.decode({
|
138
138
|
"handle" => "invalid"
|
139
139
|
})
|
140
|
-
end.
|
140
|
+
end.to raise_error(TypeError, /String to Hash/)
|
141
141
|
end
|
142
142
|
else
|
143
143
|
it "decodes DeleteTarget" do
|
@@ -147,18 +147,18 @@ describe Trino::Client::StatementClient do
|
|
147
147
|
"connectorHandle" => {}
|
148
148
|
}
|
149
149
|
})
|
150
|
-
dh.handle.
|
151
|
-
dh.handle.catalog_name.
|
152
|
-
dh.handle.connector_handle.
|
150
|
+
expect(dh.handle).to be_a_kind_of(Models::TableHandle)
|
151
|
+
expect(dh.handle.catalog_name).to eq "c1"
|
152
|
+
expect(dh.handle.connector_handle).to eq({})
|
153
153
|
end
|
154
154
|
|
155
155
|
it "validates models" do
|
156
|
-
|
156
|
+
expect do
|
157
157
|
Models::DeleteTarget.decode({
|
158
158
|
"catalogName" => "c1",
|
159
159
|
"handle" => "invalid"
|
160
160
|
})
|
161
|
-
end.
|
161
|
+
end.to raise_error(TypeError, /String to Hash/)
|
162
162
|
end
|
163
163
|
end
|
164
164
|
|
@@ -167,7 +167,7 @@ describe Trino::Client::StatementClient do
|
|
167
167
|
with(body: query).to_return(body: response_json2.to_json, headers: {"X-Test-Header" => "123"})
|
168
168
|
|
169
169
|
sc = StatementClient.new(faraday, query, options.merge(http_open_timeout: 1))
|
170
|
-
sc.current_results_headers["X-Test-Header"].
|
170
|
+
expect(sc.current_results_headers["X-Test-Header"]).to eq "123"
|
171
171
|
end
|
172
172
|
|
173
173
|
it "receives headers of POST through Query" do
|
@@ -175,7 +175,7 @@ describe Trino::Client::StatementClient do
|
|
175
175
|
with(body: query).to_return(body: response_json2.to_json, headers: {"X-Test-Header" => "123"})
|
176
176
|
|
177
177
|
q = Trino::Client.new(options).query(query)
|
178
|
-
q.current_results_headers["X-Test-Header"].
|
178
|
+
expect(q.current_results_headers["X-Test-Header"]).to eq "123"
|
179
179
|
end
|
180
180
|
|
181
181
|
describe "#query_id" do
|
@@ -187,10 +187,10 @@ describe Trino::Client::StatementClient do
|
|
187
187
|
to_return(body: response_json.to_json, headers: {"X-Test-Header" => "123"})
|
188
188
|
|
189
189
|
sc = StatementClient.new(faraday, query, options.merge(http_open_timeout: 1))
|
190
|
-
sc.query_id.
|
191
|
-
sc.has_next
|
192
|
-
sc.advance.
|
193
|
-
sc.query_id.
|
190
|
+
expect(sc.query_id).to eq "queryid"
|
191
|
+
expect(sc.has_next?).to eq true
|
192
|
+
expect(sc.advance).to eq true
|
193
|
+
expect(sc.query_id).to eq "queryid"
|
194
194
|
end
|
195
195
|
end
|
196
196
|
|
@@ -214,21 +214,21 @@ describe Trino::Client::StatementClient do
|
|
214
214
|
end
|
215
215
|
|
216
216
|
it "raises an exception with sample JSON if response is unexpected" do
|
217
|
-
|
217
|
+
expect do
|
218
218
|
stub_request(:get, "http://localhost/v1/query/#{response_json2[:id]}").
|
219
219
|
with(headers: headers).
|
220
220
|
to_return(body: {"session" => "invalid session structure"}.to_json)
|
221
221
|
statement_client.query_info
|
222
|
-
end.
|
222
|
+
end.to raise_error(TrinoHttpError, /Trino API returned unexpected structure at \/v1\/query\/queryid\. Expected Trino::Client::ModelVersions::.*::QueryInfo but got {"session":"invalid session structure"}/)
|
223
223
|
end
|
224
224
|
|
225
225
|
it "raises an exception if response format is unexpected" do
|
226
|
-
|
226
|
+
expect do
|
227
227
|
stub_request(:get, "http://localhost/v1/query/#{response_json2[:id]}").
|
228
228
|
with(headers: headers).
|
229
229
|
to_return(body: "unexpected data structure (not JSON)")
|
230
230
|
statement_client.query_info
|
231
|
-
end.
|
231
|
+
end.to raise_error(TrinoHttpError, /Trino API returned unexpected data format./)
|
232
232
|
end
|
233
233
|
|
234
234
|
it "is redirected if server returned 301" do
|
@@ -241,7 +241,7 @@ describe Trino::Client::StatementClient do
|
|
241
241
|
to_return(body: {"queryId" => "queryid"}.to_json)
|
242
242
|
|
243
243
|
query_info = statement_client.query_info
|
244
|
-
query_info.query_id.
|
244
|
+
expect(query_info.query_id).to eq "queryid"
|
245
245
|
end
|
246
246
|
end
|
247
247
|
|
@@ -251,14 +251,14 @@ describe Trino::Client::StatementClient do
|
|
251
251
|
it "sends DELETE request with empty body to /v1/query/{queryId}" do
|
252
252
|
stub_request(:delete, "http://localhost/v1/query/#{query_id}").
|
253
253
|
with(body: "",
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
254
|
+
headers: {
|
255
|
+
"User-Agent" => "trino-ruby/#{VERSION}",
|
256
|
+
"X-Trino-Catalog" => options[:catalog],
|
257
|
+
"X-Trino-Schema" => options[:schema],
|
258
|
+
"X-Trino-User" => options[:user],
|
259
|
+
"X-Trino-Language" => options[:language],
|
260
|
+
"X-Trino-Time-Zone" => options[:time_zone],
|
261
|
+
}).to_return(body: {}.to_json)
|
262
262
|
|
263
263
|
Trino::Client.new(options).kill(query_id)
|
264
264
|
end
|
@@ -277,13 +277,13 @@ describe Trino::Client::StatementClient do
|
|
277
277
|
end
|
278
278
|
|
279
279
|
it "sets X-Trino-Session from properties" do
|
280
|
-
options[:properties] = {"hello" => "world", "name"=>"value"}
|
280
|
+
options[:properties] = {"hello" => "world", "name" => "value"}
|
281
281
|
|
282
282
|
stub_request(:post, "localhost/v1/statement").
|
283
283
|
with(body: query,
|
284
|
-
|
285
|
-
|
286
|
-
|
284
|
+
headers: headers.merge({
|
285
|
+
"X-Trino-Session" => options[:properties].map { |k, v| "#{k}=#{v}" }.join(", ")
|
286
|
+
})).
|
287
287
|
to_return(body: response_json.to_json)
|
288
288
|
|
289
289
|
StatementClient.new(faraday, query, options)
|
@@ -294,7 +294,7 @@ describe Trino::Client::StatementClient do
|
|
294
294
|
|
295
295
|
stub_request(:post, "localhost/v1/statement").
|
296
296
|
with(body: query,
|
297
|
-
|
297
|
+
headers: headers.merge("X-Trino-Client-Info" => "raw")).
|
298
298
|
to_return(body: response_json.to_json)
|
299
299
|
|
300
300
|
StatementClient.new(faraday, query, options)
|
@@ -305,7 +305,7 @@ describe Trino::Client::StatementClient do
|
|
305
305
|
|
306
306
|
stub_request(:post, "localhost/v1/statement").
|
307
307
|
with(body: query,
|
308
|
-
|
308
|
+
headers: headers.merge("X-Trino-Client-Info" => '{"k1":"v1","k2":"v2"}')).
|
309
309
|
to_return(body: response_json.to_json)
|
310
310
|
|
311
311
|
StatementClient.new(faraday, query, options)
|
@@ -316,7 +316,7 @@ describe Trino::Client::StatementClient do
|
|
316
316
|
|
317
317
|
stub_request(:post, "localhost/v1/statement").
|
318
318
|
with(body: query,
|
319
|
-
|
319
|
+
headers: headers.merge("X-Trino-Client-Tags" => "k1:v1,k2:v2")).
|
320
320
|
to_return(body: response_json.to_json)
|
321
321
|
|
322
322
|
StatementClient.new(faraday, query, options)
|
@@ -329,28 +329,28 @@ describe Trino::Client::StatementClient do
|
|
329
329
|
it "adds basic auth headers when ssl is enabled and a password is given" do
|
330
330
|
stub_request(:post, "https://localhost/v1/statement").
|
331
331
|
with(body: query,
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
332
|
+
headers: {
|
333
|
+
"User-Agent" => "trino-ruby/#{VERSION}",
|
334
|
+
"X-Trino-Catalog" => options[:catalog],
|
335
|
+
"X-Trino-Schema" => options[:schema],
|
336
|
+
"X-Trino-User" => options[:user],
|
337
|
+
"X-Trino-Language" => options[:language],
|
338
|
+
"X-Trino-Time-Zone" => options[:time_zone],
|
339
|
+
},
|
340
|
+
basic_auth: [options[:user], password]
|
341
341
|
).to_return(body: response_json.to_json)
|
342
342
|
|
343
|
-
options.merge!(ssl: {
|
343
|
+
options.merge!(ssl: {verify: true}, password: password)
|
344
344
|
StatementClient.new(faraday, query, options)
|
345
345
|
end
|
346
346
|
|
347
347
|
it "forbids using basic auth when ssl is disabled" do
|
348
|
-
|
348
|
+
expect do
|
349
349
|
Query.__send__(:faraday_client, {
|
350
350
|
server: 'localhost',
|
351
351
|
password: 'abcd'
|
352
352
|
})
|
353
|
-
end.
|
353
|
+
end.to raise_error(ArgumentError)
|
354
354
|
end
|
355
355
|
end
|
356
356
|
|
@@ -359,7 +359,7 @@ describe Trino::Client::StatementClient do
|
|
359
359
|
f = Query.__send__(:faraday_client, {
|
360
360
|
server: "localhost",
|
361
361
|
})
|
362
|
-
f.url_prefix.to_s.
|
362
|
+
expect(f.url_prefix.to_s).to eq "http://localhost/"
|
363
363
|
end
|
364
364
|
|
365
365
|
it "is enabled with ssl: true" do
|
@@ -367,8 +367,8 @@ describe Trino::Client::StatementClient do
|
|
367
367
|
server: "localhost",
|
368
368
|
ssl: true,
|
369
369
|
})
|
370
|
-
f.url_prefix.to_s.
|
371
|
-
f.ssl.verify
|
370
|
+
expect(f.url_prefix.to_s).to eq "https://localhost/"
|
371
|
+
expect(f.ssl.verify?).to eq true
|
372
372
|
end
|
373
373
|
|
374
374
|
it "is enabled with ssl: {verify: false}" do
|
@@ -376,17 +376,17 @@ describe Trino::Client::StatementClient do
|
|
376
376
|
server: "localhost",
|
377
377
|
ssl: {verify: false}
|
378
378
|
})
|
379
|
-
f.url_prefix.to_s.
|
380
|
-
f.ssl.verify
|
379
|
+
expect(f.url_prefix.to_s).to eq "https://localhost/"
|
380
|
+
expect(f.ssl.verify?).to eq false
|
381
381
|
end
|
382
382
|
|
383
383
|
it "rejects invalid ssl: verify: object" do
|
384
|
-
|
384
|
+
expect do
|
385
385
|
f = Query.__send__(:faraday_client, {
|
386
386
|
server: "localhost",
|
387
387
|
ssl: {verify: "??"}
|
388
388
|
})
|
389
|
-
end.
|
389
|
+
end.to raise_error(ArgumentError, /String/)
|
390
390
|
end
|
391
391
|
|
392
392
|
it "is enabled with ssl: Hash" do
|
@@ -405,31 +405,31 @@ describe Trino::Client::StatementClient do
|
|
405
405
|
ssl: ssl,
|
406
406
|
})
|
407
407
|
|
408
|
-
f.url_prefix.to_s.
|
409
|
-
f.ssl.verify
|
410
|
-
f.ssl.ca_file.
|
411
|
-
f.ssl.ca_path.
|
412
|
-
f.ssl.cert_store.
|
413
|
-
f.ssl.client_cert.
|
414
|
-
f.ssl.client_key.
|
408
|
+
expect(f.url_prefix.to_s).to eq "https://localhost/"
|
409
|
+
expect(f.ssl.verify?).to eq true
|
410
|
+
expect(f.ssl.ca_file).to eq ssl[:ca_file]
|
411
|
+
expect(f.ssl.ca_path).to eq ssl[:ca_path]
|
412
|
+
expect(f.ssl.cert_store).to eq ssl[:cert_store]
|
413
|
+
expect(f.ssl.client_cert).to eq ssl[:client_cert]
|
414
|
+
expect(f.ssl.client_key).to eq ssl[:client_key]
|
415
415
|
end
|
416
416
|
|
417
417
|
it "rejects an invalid string" do
|
418
|
-
|
418
|
+
expect do
|
419
419
|
Query.__send__(:faraday_client, {
|
420
420
|
server: "localhost",
|
421
421
|
ssl: '??',
|
422
422
|
})
|
423
|
-
end.
|
423
|
+
end.to raise_error(ArgumentError, /String/)
|
424
424
|
end
|
425
425
|
|
426
426
|
it "rejects an integer" do
|
427
|
-
|
427
|
+
expect do
|
428
428
|
Query.__send__(:faraday_client, {
|
429
429
|
server: "localhost",
|
430
430
|
ssl: 3,
|
431
431
|
})
|
432
|
-
end.
|
432
|
+
end.to raise_error(ArgumentError, /:ssl/)
|
433
433
|
end
|
434
434
|
end
|
435
435
|
|
@@ -440,16 +440,15 @@ describe Trino::Client::StatementClient do
|
|
440
440
|
|
441
441
|
faraday = Faraday.new(url: "http://localhost")
|
442
442
|
client = StatementClient.new(faraday, query, options.merge(model_version: "316"))
|
443
|
-
client.current_results.
|
443
|
+
expect(client.current_results).to be_a_kind_of(ModelVersions::V316::QueryResults)
|
444
444
|
end
|
445
445
|
|
446
446
|
it "rejects unsupported model version" do
|
447
|
-
|
447
|
+
expect do
|
448
448
|
StatementClient.new(faraday, query, options.merge(model_version: "0.111"))
|
449
|
-
end.
|
449
|
+
end.to raise_error(NameError)
|
450
450
|
end
|
451
451
|
|
452
|
-
|
453
452
|
let :nested_json do
|
454
453
|
nested_stats = {createTime: Time.now}
|
455
454
|
# JSON max nesting default value is 100
|
@@ -465,14 +464,14 @@ describe Trino::Client::StatementClient do
|
|
465
464
|
it "parse nested json properly" do
|
466
465
|
stub_request(:post, "localhost/v1/statement").
|
467
466
|
with(body: query,
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
467
|
+
headers: {
|
468
|
+
"User-Agent" => "trino-ruby/#{VERSION}",
|
469
|
+
"X-Trino-Catalog" => options[:catalog],
|
470
|
+
"X-Trino-Schema" => options[:schema],
|
471
|
+
"X-Trino-User" => options[:user],
|
472
|
+
"X-Trino-Language" => options[:language],
|
473
|
+
"X-Trino-Time-Zone" => options[:time_zone],
|
474
|
+
}).to_return(body: nested_json.to_json(:max_nesting => false))
|
476
475
|
|
477
476
|
StatementClient.new(faraday, query, options)
|
478
477
|
end
|
@@ -544,29 +543,29 @@ describe Trino::Client::StatementClient do
|
|
544
543
|
stub_request(:get, "localhost/v1/next_uri").
|
545
544
|
with(headers: headers).
|
546
545
|
to_return(body: planning_response.to_json)
|
547
|
-
|
546
|
+
expect do
|
548
547
|
client.advance
|
549
|
-
end.
|
548
|
+
end.to raise_error(Trino::Client::TrinoQueryTimeoutError, "Query queryid timed out")
|
550
549
|
end
|
551
550
|
|
552
551
|
it "raises TrinoQueryTimeoutError if timeout during initial resuming" do
|
553
552
|
stub_request(:get, "localhost/v1/next_uri").
|
554
553
|
with(headers: headers).
|
555
|
-
to_return(body: lambda{|req| raise Timeout::Error.new("execution expired")})
|
554
|
+
to_return(body: lambda { |req| raise Timeout::Error.new("execution expired") })
|
556
555
|
|
557
|
-
|
556
|
+
expect do
|
558
557
|
StatementClient.new(faraday, query, options.merge(timeout_type => 1), "/v1/next_uri")
|
559
|
-
end.
|
558
|
+
end.to raise_error(Trino::Client::TrinoQueryTimeoutError, "Query timed out")
|
560
559
|
end
|
561
560
|
|
562
561
|
it "raises TrinoHttpError if timeout during initial resuming and #{timeout_type} < retry_timeout" do
|
563
562
|
stub_request(:get, "localhost/v1/next_uri").
|
564
563
|
with(headers: headers).
|
565
|
-
to_return(body: lambda{|req| raise Timeout::Error.new("execution expired")})
|
564
|
+
to_return(body: lambda { |req| raise Timeout::Error.new("execution expired") })
|
566
565
|
|
567
|
-
|
566
|
+
expect do
|
568
567
|
StatementClient.new(faraday, query, options.merge(timeout_type => 2, retry_timeout: 1), "/v1/next_uri")
|
569
|
-
end.
|
568
|
+
end.to raise_error(Trino::Client::TrinoHttpError, "Trino API error due to timeout")
|
570
569
|
end
|
571
570
|
end
|
572
571
|
|
@@ -606,9 +605,9 @@ describe Trino::Client::StatementClient do
|
|
606
605
|
stub_request(:get, "localhost/v1/next_uri").
|
607
606
|
with(headers: headers).
|
608
607
|
to_return(body: late_running_response.to_json)
|
609
|
-
|
608
|
+
expect do
|
610
609
|
client.advance
|
611
|
-
end.
|
610
|
+
end.to raise_error(Trino::Client::TrinoQueryTimeoutError, "Query queryid timed out")
|
612
611
|
end
|
613
612
|
|
614
613
|
it "doesn't raise errors if query is done" do
|
@@ -631,7 +630,5 @@ describe Trino::Client::StatementClient do
|
|
631
630
|
sleep 1
|
632
631
|
client.advance # set finished
|
633
632
|
end
|
634
|
-
|
635
633
|
end
|
636
634
|
end
|
637
|
-
|
data/spec/tpch_query_spec.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require
|
1
|
+
require "trino-client"
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path
|
1
|
+
require File.expand_path "../lib/trino/client/version", File.dirname(__FILE__)
|
2
2
|
|
3
3
|
Gem::Specification.new do |gem|
|
4
4
|
gem.name = "trino-client-ruby"
|
@@ -6,12 +6,12 @@ Gem::Specification.new do |gem|
|
|
6
6
|
|
7
7
|
gem.authors = ["Sadayuki Furuhashi"]
|
8
8
|
gem.email = ["sf@treasure-data.com"]
|
9
|
-
gem.description =
|
10
|
-
gem.summary =
|
9
|
+
gem.description = "Trino client library"
|
10
|
+
gem.summary = "Trino client library"
|
11
11
|
gem.homepage = "https://github.com/treasure-data/trino-client-ruby"
|
12
12
|
gem.license = "Apache-2.0"
|
13
13
|
|
14
|
-
gem.files = [
|
14
|
+
gem.files = ["lib/trino-client-ruby.rb"]
|
15
15
|
gem.require_paths = ["lib"]
|
16
16
|
|
17
17
|
gem.required_ruby_version = ">= 1.9.1"
|
data/trino-client.gemspec
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path
|
1
|
+
require File.expand_path "lib/trino/client/version", File.dirname(__FILE__)
|
2
2
|
|
3
3
|
Gem::Specification.new do |gem|
|
4
4
|
gem.name = "trino-client"
|
@@ -6,25 +6,27 @@ Gem::Specification.new do |gem|
|
|
6
6
|
|
7
7
|
gem.authors = ["Sadayuki Furuhashi"]
|
8
8
|
gem.email = ["sf@treasure-data.com"]
|
9
|
-
gem.description =
|
10
|
-
gem.summary =
|
9
|
+
gem.description = "Trino client library"
|
10
|
+
gem.summary = "Trino client library"
|
11
11
|
gem.homepage = "https://github.com/treasure-data/trino-client-ruby"
|
12
12
|
gem.license = "Apache-2.0"
|
13
13
|
|
14
14
|
gem.files = `git ls-files`.split($\)
|
15
|
-
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
16
|
-
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
15
|
+
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
17
16
|
gem.require_paths = ["lib"]
|
18
17
|
|
19
|
-
gem.required_ruby_version = ">=
|
18
|
+
gem.required_ruby_version = ">= 2.7.0"
|
20
19
|
|
21
|
-
gem.add_dependency "faraday",
|
22
|
-
gem.add_dependency "
|
23
|
-
|
20
|
+
gem.add_dependency "faraday", ">= 1", "< 3"
|
21
|
+
gem.add_dependency "faraday-gzip", ">= 1"
|
22
|
+
gem.add_dependency "faraday-follow_redirects", ">= 0.3"
|
23
|
+
gem.add_dependency "msgpack", [">= 1.5.1"]
|
24
24
|
|
25
|
-
gem.add_development_dependency "rake", [">= 0.9.2", "<
|
26
|
-
gem.add_development_dependency "rspec",
|
25
|
+
gem.add_development_dependency "rake", [">= 0.9.2", "< 14.0"]
|
26
|
+
gem.add_development_dependency "rspec", "~> 3.12.0"
|
27
27
|
gem.add_development_dependency "webmock", ["~> 3.0"]
|
28
|
-
gem.add_development_dependency "addressable",
|
29
|
-
gem.add_development_dependency "simplecov",
|
28
|
+
gem.add_development_dependency "addressable", "~> 2.8.1" # 2.5.0 doesn't support Ruby 1.9.3
|
29
|
+
gem.add_development_dependency "simplecov", "~> 0.22.0"
|
30
|
+
gem.add_development_dependency "standard", "~> 1.24.3"
|
31
|
+
gem.add_development_dependency "psych", "~> 3"
|
30
32
|
end
|