trino-client 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,634 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Trino::Client::StatementClient do
4
- let :options do
5
- {
6
- server: "localhost",
7
- user: "frsyuki",
8
- catalog: "native",
9
- schema: "default",
10
- time_zone: "US/Pacific",
11
- language: "ja_JP",
12
- debug: true,
13
- follow_redirect: true
14
- }
15
- end
16
-
17
- let :query do
18
- "select * from sys.node"
19
- end
20
-
21
- let :response_json do
22
- {
23
- id: "queryid",
24
- stats: {}
25
- }
26
- end
27
-
28
- let :faraday do
29
- Trino::Client.faraday_client(options)
30
- end
31
-
32
- it "sets headers" do
33
- stub_request(:post, "localhost/v1/statement").
34
- with(body: query,
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
-
44
- StatementClient.new(faraday, query, options)
45
- end
46
-
47
- let :response_json2 do
48
- {
49
- id: "queryid",
50
- nextUri: 'http://localhost/v1/next_uri',
51
- stats: {}
52
- }
53
- end
54
-
55
- it "sets headers" do
56
- retry_p = false
57
- stub_request(:post, "localhost/v1/statement").
58
- with(body: query,
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
-
68
- stub_request(:get, "localhost/v1/next_uri").
69
- with(headers: {
70
- "User-Agent" => "trino-ruby/#{VERSION}",
71
- "X-Trino-Catalog" => options[:catalog],
72
- "X-Trino-Schema" => options[:schema],
73
- "X-Trino-User" => options[:user],
74
- "X-Trino-Language" => options[:language],
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 })
77
-
78
- sc = StatementClient.new(faraday, query, options.merge(http_open_timeout: 1))
79
- expect(sc.has_next?).to eq true
80
- expect(sc.advance).to eq true
81
- expect(retry_p).to eq true
82
- end
83
-
84
- it "uses 'Accept: application/x-msgpack' if option is set" do
85
- retry_p = false
86
- stub_request(:post, "localhost/v1/statement").
87
- with(body: query,
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
-
98
- stub_request(:get, "localhost/v1/next_uri").
99
- with(headers: {
100
- "User-Agent" => "trino-ruby/#{VERSION}",
101
- "X-Trino-Catalog" => options[:catalog],
102
- "X-Trino-Schema" => options[:schema],
103
- "X-Trino-User" => options[:user],
104
- "X-Trino-Language" => options[:language],
105
- "X-Trino-Time-Zone" => options[:time_zone],
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"})
108
-
109
- options.merge!(http_open_timeout: 1, enable_x_msgpack: "application/x-msgpack")
110
- sc = StatementClient.new(faraday, query, options)
111
- expect(sc.has_next?).to eq true
112
- expect(sc.advance).to eq true
113
- expect(retry_p).to eq true
114
- end
115
-
116
- # trino version could be "V0_ddd" or "Vddd"
117
- /\Trino::Client::ModelVersions::V(\w+)/ =~ Trino::Client::Models.to_s
118
-
119
- # https://github.com/prestosql/presto/commit/80a2c5113d47e3390bf6dc041486a1c9dfc04592
120
- # renamed DeleteHandle to DeleteTarget, then DeleteHandle exists when trino version
121
- # is less than 313.
122
- if $1[0, 2] == "0_" || $1.to_i < 314
123
- it "decodes DeleteHandle" do
124
- dh = Models::DeleteHandle.decode({
125
- "handle" => {
126
- "connectorId" => "c1",
127
- "connectorHandle" => {}
128
- }
129
- })
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
- end
134
-
135
- it "validates models" do
136
- expect do
137
- Models::DeleteHandle.decode({
138
- "handle" => "invalid"
139
- })
140
- end.to raise_error(TypeError, /String to Hash/)
141
- end
142
- else
143
- it "decodes DeleteTarget" do
144
- dh = Models::DeleteTarget.decode({
145
- "handle" => {
146
- "catalogName" => "c1",
147
- "connectorHandle" => {}
148
- }
149
- })
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
- end
154
-
155
- it "validates models" do
156
- expect do
157
- Models::DeleteTarget.decode({
158
- "catalogName" => "c1",
159
- "handle" => "invalid"
160
- })
161
- end.to raise_error(TypeError, /String to Hash/)
162
- end
163
- end
164
-
165
- it "receives headers of POST" do
166
- stub_request(:post, "localhost/v1/statement").
167
- with(body: query).to_return(body: response_json2.to_json, headers: {"X-Test-Header" => "123"})
168
-
169
- sc = StatementClient.new(faraday, query, options.merge(http_open_timeout: 1))
170
- expect(sc.current_results_headers["X-Test-Header"]).to eq "123"
171
- end
172
-
173
- it "receives headers of POST through Query" do
174
- stub_request(:post, "localhost/v1/statement").
175
- with(body: query).to_return(body: response_json2.to_json, headers: {"X-Test-Header" => "123"})
176
-
177
- q = Trino::Client.new(options).query(query)
178
- expect(q.current_results_headers["X-Test-Header"]).to eq "123"
179
- end
180
-
181
- describe "#query_id" do
182
- it "returns query_id" do
183
- stub_request(:post, "localhost/v1/statement").
184
- with(body: query).to_return(body: response_json2.to_json, headers: {"X-Test-Header" => "123"})
185
-
186
- stub_request(:get, "localhost/v1/next_uri").
187
- to_return(body: response_json.to_json, headers: {"X-Test-Header" => "123"})
188
-
189
- sc = StatementClient.new(faraday, query, options.merge(http_open_timeout: 1))
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
- end
195
- end
196
-
197
- describe '#query_info' do
198
- let :headers do
199
- {
200
- "User-Agent" => "trino-ruby/#{VERSION}",
201
- "X-Trino-Catalog" => options[:catalog],
202
- "X-Trino-Schema" => options[:schema],
203
- "X-Trino-User" => options[:user],
204
- "X-Trino-Language" => options[:language],
205
- "X-Trino-Time-Zone" => options[:time_zone],
206
- }
207
- end
208
-
209
- let :statement_client do
210
- stub_request(:post, "http://localhost/v1/statement").
211
- with(body: query, headers: headers).
212
- to_return(body: response_json2.to_json)
213
- StatementClient.new(faraday, query, options)
214
- end
215
-
216
- it "raises an exception with sample JSON if response is unexpected" do
217
- expect do
218
- stub_request(:get, "http://localhost/v1/query/#{response_json2[:id]}").
219
- with(headers: headers).
220
- to_return(body: {"session" => "invalid session structure"}.to_json)
221
- statement_client.query_info
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
- end
224
-
225
- it "raises an exception if response format is unexpected" do
226
- expect do
227
- stub_request(:get, "http://localhost/v1/query/#{response_json2[:id]}").
228
- with(headers: headers).
229
- to_return(body: "unexpected data structure (not JSON)")
230
- statement_client.query_info
231
- end.to raise_error(TrinoHttpError, /Trino API returned unexpected data format./)
232
- end
233
-
234
- it "is redirected if server returned 301" do
235
- stub_request(:get, "http://localhost/v1/query/#{response_json2[:id]}").
236
- with(headers: headers).
237
- to_return(status: 301, headers: {"Location" => "http://localhost/v1/query/redirected"})
238
-
239
- stub_request(:get, "http://localhost/v1/query/redirected").
240
- with(headers: headers).
241
- to_return(body: {"queryId" => "queryid"}.to_json)
242
-
243
- query_info = statement_client.query_info
244
- expect(query_info.query_id).to eq "queryid"
245
- end
246
- end
247
-
248
- describe "Killing a query" do
249
- let(:query_id) { 'A_QUERY_ID' }
250
-
251
- it "sends DELETE request with empty body to /v1/query/{queryId}" do
252
- stub_request(:delete, "http://localhost/v1/query/#{query_id}").
253
- with(body: "",
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
-
263
- Trino::Client.new(options).kill(query_id)
264
- end
265
- end
266
-
267
- describe 'advanced HTTP headers' do
268
- let(:headers) do
269
- {
270
- "User-Agent" => "trino-ruby/#{VERSION}",
271
- "X-Trino-Catalog" => options[:catalog],
272
- "X-Trino-Schema" => options[:schema],
273
- "X-Trino-User" => options[:user],
274
- "X-Trino-Language" => options[:language],
275
- "X-Trino-Time-Zone" => options[:time_zone],
276
- }
277
- end
278
-
279
- it "sets X-Trino-Session from properties" do
280
- options[:properties] = {"hello" => "world", "name" => "value"}
281
-
282
- stub_request(:post, "localhost/v1/statement").
283
- with(body: query,
284
- headers: headers.merge({
285
- "X-Trino-Session" => options[:properties].map { |k, v| "#{k}=#{v}" }.join(", ")
286
- })).
287
- to_return(body: response_json.to_json)
288
-
289
- StatementClient.new(faraday, query, options)
290
- end
291
-
292
- it "sets X-Trino-Client-Info from client_info" do
293
- options[:client_info] = "raw"
294
-
295
- stub_request(:post, "localhost/v1/statement").
296
- with(body: query,
297
- headers: headers.merge("X-Trino-Client-Info" => "raw")).
298
- to_return(body: response_json.to_json)
299
-
300
- StatementClient.new(faraday, query, options)
301
- end
302
-
303
- it "sets X-Trino-Client-Info in JSON from client_info" do
304
- options[:client_info] = {"k1" => "v1", "k2" => "v2"}
305
-
306
- stub_request(:post, "localhost/v1/statement").
307
- with(body: query,
308
- headers: headers.merge("X-Trino-Client-Info" => '{"k1":"v1","k2":"v2"}')).
309
- to_return(body: response_json.to_json)
310
-
311
- StatementClient.new(faraday, query, options)
312
- end
313
-
314
- it "sets X-Trino-Client-Tags" do
315
- options[:client_tags] = ["k1:v1", "k2:v2"]
316
-
317
- stub_request(:post, "localhost/v1/statement").
318
- with(body: query,
319
- headers: headers.merge("X-Trino-Client-Tags" => "k1:v1,k2:v2")).
320
- to_return(body: response_json.to_json)
321
-
322
- StatementClient.new(faraday, query, options)
323
- end
324
- end
325
-
326
- describe 'HTTP basic auth' do
327
- let(:password) { 'abcd' }
328
-
329
- it "adds basic auth headers when ssl is enabled and a password is given" do
330
- stub_request(:post, "https://localhost/v1/statement").
331
- with(body: query,
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
- ).to_return(body: response_json.to_json)
342
-
343
- options.merge!(ssl: {verify: true}, password: password)
344
- StatementClient.new(faraday, query, options)
345
- end
346
-
347
- it "forbids using basic auth when ssl is disabled" do
348
- expect do
349
- Query.__send__(:faraday_client, {
350
- server: 'localhost',
351
- password: 'abcd'
352
- })
353
- end.to raise_error(ArgumentError)
354
- end
355
- end
356
-
357
- describe "ssl" do
358
- it "is disabled by default" do
359
- f = Query.__send__(:faraday_client, {
360
- server: "localhost",
361
- })
362
- expect(f.url_prefix.to_s).to eq "http://localhost/"
363
- end
364
-
365
- it "is enabled with ssl: true" do
366
- f = Query.__send__(:faraday_client, {
367
- server: "localhost",
368
- ssl: true,
369
- })
370
- expect(f.url_prefix.to_s).to eq "https://localhost/"
371
- expect(f.ssl.verify?).to eq true
372
- end
373
-
374
- it "is enabled with ssl: {verify: false}" do
375
- f = Query.__send__(:faraday_client, {
376
- server: "localhost",
377
- ssl: {verify: false}
378
- })
379
- expect(f.url_prefix.to_s).to eq "https://localhost/"
380
- expect(f.ssl.verify?).to eq false
381
- end
382
-
383
- it "rejects invalid ssl: verify: object" do
384
- expect do
385
- f = Query.__send__(:faraday_client, {
386
- server: "localhost",
387
- ssl: {verify: "??"}
388
- })
389
- end.to raise_error(ArgumentError, /String/)
390
- end
391
-
392
- it "is enabled with ssl: Hash" do
393
- require 'openssl'
394
-
395
- ssl = {
396
- ca_file: "/path/to/dummy.pem",
397
- ca_path: "/path/to/pemdir",
398
- cert_store: OpenSSL::X509::Store.new,
399
- client_cert: OpenSSL::X509::Certificate.new,
400
- client_key: OpenSSL::PKey::DSA.new,
401
- }
402
-
403
- f = Query.__send__(:faraday_client, {
404
- server: "localhost",
405
- ssl: ssl,
406
- })
407
-
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
- end
416
-
417
- it "rejects an invalid string" do
418
- expect do
419
- Query.__send__(:faraday_client, {
420
- server: "localhost",
421
- ssl: '??',
422
- })
423
- end.to raise_error(ArgumentError, /String/)
424
- end
425
-
426
- it "rejects an integer" do
427
- expect do
428
- Query.__send__(:faraday_client, {
429
- server: "localhost",
430
- ssl: 3,
431
- })
432
- end.to raise_error(ArgumentError, /:ssl/)
433
- end
434
- end
435
-
436
- it "supports Presto" do
437
- stub_request(:post, "localhost/v1/statement").
438
- with({body: query}).
439
- to_return(body: response_json.to_json)
440
-
441
- faraday = Faraday.new(url: "http://localhost")
442
- client = StatementClient.new(faraday, query, options.merge(model_version: "316"))
443
- expect(client.current_results).to be_a_kind_of(ModelVersions::V316::QueryResults)
444
- end
445
-
446
- it "rejects unsupported model version" do
447
- expect do
448
- StatementClient.new(faraday, query, options.merge(model_version: "0.111"))
449
- end.to raise_error(NameError)
450
- end
451
-
452
- let :nested_json do
453
- nested_stats = {createTime: Time.now}
454
- # JSON max nesting default value is 100
455
- for i in 0..100 do
456
- nested_stats = {stats: nested_stats}
457
- end
458
- {
459
- id: "queryid",
460
- stats: nested_stats
461
- }
462
- end
463
-
464
- it "parse nested json properly" do
465
- stub_request(:post, "localhost/v1/statement").
466
- with(body: query,
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))
475
-
476
- StatementClient.new(faraday, query, options)
477
- end
478
-
479
- describe "query timeout" do
480
- let :headers do
481
- {
482
- "User-Agent" => "trino-ruby/#{VERSION}",
483
- "X-Trino-Catalog" => options[:catalog],
484
- "X-Trino-Schema" => options[:schema],
485
- "X-Trino-User" => options[:user],
486
- "X-Trino-Language" => options[:language],
487
- "X-Trino-Time-Zone" => options[:time_zone],
488
- }
489
- end
490
-
491
- let :planning_response do
492
- {
493
- id: "queryid",
494
- nextUri: 'http://localhost/v1/next_uri',
495
- stats: {},
496
- }
497
- end
498
-
499
- let :early_running_response do
500
- {
501
- id: "queryid",
502
- nextUri: 'http://localhost/v1/next_uri',
503
- stats: {},
504
- columns: [{name: "_col0", type: "bigint"}],
505
- }
506
- end
507
-
508
- let :late_running_response do
509
- {
510
- id: "queryid",
511
- nextUri: 'http://localhost/v1/next_uri',
512
- stats: {},
513
- columns: [{name: "_col0", type: "bigint"}],
514
- data: "",
515
- }
516
- end
517
-
518
- let :done_response do
519
- {
520
- id: "queryid",
521
- stats: {},
522
- columns: [{name: "_col0", type: "bigint"}],
523
- }
524
- end
525
-
526
- before(:each) do
527
- end
528
-
529
- [:plan_timeout, :query_timeout].each do |timeout_type|
530
- it "raises TrinoQueryTimeoutError if timeout during planning" do
531
- stub_request(:post, "localhost/v1/statement").
532
- with(body: query, headers: headers).
533
- to_return(body: planning_response.to_json)
534
-
535
- client = StatementClient.new(faraday, query, options.merge(timeout_type => 1))
536
-
537
- stub_request(:get, "localhost/v1/next_uri").
538
- with(headers: headers).
539
- to_return(body: planning_response.to_json)
540
- client.advance
541
-
542
- sleep 1
543
- stub_request(:get, "localhost/v1/next_uri").
544
- with(headers: headers).
545
- to_return(body: planning_response.to_json)
546
- expect do
547
- client.advance
548
- end.to raise_error(Trino::Client::TrinoQueryTimeoutError, "Query queryid timed out")
549
- end
550
-
551
- it "raises TrinoQueryTimeoutError if timeout during initial resuming" do
552
- stub_request(:get, "localhost/v1/next_uri").
553
- with(headers: headers).
554
- to_return(body: lambda { |req| raise Timeout::Error.new("execution expired") })
555
-
556
- expect do
557
- StatementClient.new(faraday, query, options.merge(timeout_type => 1), "/v1/next_uri")
558
- end.to raise_error(Trino::Client::TrinoQueryTimeoutError, "Query timed out")
559
- end
560
-
561
- it "raises TrinoHttpError if timeout during initial resuming and #{timeout_type} < retry_timeout" do
562
- stub_request(:get, "localhost/v1/next_uri").
563
- with(headers: headers).
564
- to_return(body: lambda { |req| raise Timeout::Error.new("execution expired") })
565
-
566
- expect do
567
- StatementClient.new(faraday, query, options.merge(timeout_type => 2, retry_timeout: 1), "/v1/next_uri")
568
- end.to raise_error(Trino::Client::TrinoHttpError, "Trino API error due to timeout")
569
- end
570
- end
571
-
572
- it "doesn't raise errors with plan_timeout if query planning is done" do
573
- stub_request(:post, "localhost/v1/statement").
574
- with(body: query, headers: headers).
575
- to_return(body: planning_response.to_json)
576
-
577
- client = StatementClient.new(faraday, query, options.merge(plan_timeout: 1))
578
-
579
- sleep 1
580
-
581
- stub_request(:get, "localhost/v1/next_uri").
582
- with(headers: headers).
583
- to_return(body: early_running_response.to_json)
584
- client.advance
585
-
586
- stub_request(:get, "localhost/v1/next_uri").
587
- with(headers: headers).
588
- to_return(body: late_running_response.to_json)
589
- client.advance
590
- end
591
-
592
- it "raises TrinoQueryTimeoutError if timeout during execution" do
593
- stub_request(:post, "localhost/v1/statement").
594
- with(body: query, headers: headers).
595
- to_return(body: planning_response.to_json)
596
-
597
- client = StatementClient.new(faraday, query, options.merge(query_timeout: 1))
598
-
599
- stub_request(:get, "localhost/v1/next_uri").
600
- with(headers: headers).
601
- to_return(body: early_running_response.to_json)
602
- client.advance
603
-
604
- sleep 1
605
- stub_request(:get, "localhost/v1/next_uri").
606
- with(headers: headers).
607
- to_return(body: late_running_response.to_json)
608
- expect do
609
- client.advance
610
- end.to raise_error(Trino::Client::TrinoQueryTimeoutError, "Query queryid timed out")
611
- end
612
-
613
- it "doesn't raise errors if query is done" do
614
- stub_request(:post, "localhost/v1/statement").
615
- with(body: query, headers: headers).
616
- to_return(body: planning_response.to_json)
617
-
618
- client = StatementClient.new(faraday, query, options.merge(query_timeout: 1))
619
-
620
- stub_request(:get, "localhost/v1/next_uri").
621
- with(headers: headers).
622
- to_return(body: early_running_response.to_json)
623
- client.advance
624
-
625
- stub_request(:get, "localhost/v1/next_uri").
626
- with(headers: headers).
627
- to_return(body: done_response.to_json)
628
- client.advance # set finished
629
-
630
- sleep 1
631
- client.advance # set finished
632
- end
633
- end
634
- end
data/spec/tpch/q01.sql DELETED
@@ -1,21 +0,0 @@
1
- SELECT
2
- l.returnflag,
3
- l.linestatus,
4
- sum(l.quantity) AS sum_qty,
5
- sum(l.extendedprice) AS sum_base_price,
6
- sum(l.extendedprice * (1 - l.discount)) AS sum_disc_price,
7
- sum(l.extendedprice * (1 - l.discount) * (1 + l.tax)) AS sum_charge,
8
- avg(l.quantity) AS avg_qty,
9
- avg(l.extendedprice) AS avg_price,
10
- avg(l.discount) AS avg_disc,
11
- count(*) AS count_order
12
- FROM
13
- "tpch"."tiny"."lineitem" AS l
14
- WHERE
15
- l.shipdate <= DATE '1998-12-01' - INTERVAL '90' DAY
16
- GROUP BY
17
- l.returnflag,
18
- l.linestatus
19
- ORDER BY
20
- l.returnflag,
21
- l.linestatus
data/spec/tpch/q02.sql DELETED
@@ -1,43 +0,0 @@
1
- SELECT
2
- s.acctbal,
3
- s.name,
4
- n.name,
5
- p.partkey,
6
- p.mfgr,
7
- s.address,
8
- s.phone,
9
- s.comment
10
- FROM
11
- "tpch"."tiny"."part" p,
12
- "tpch"."tiny"."supplier" s,
13
- "tpch"."tiny"."partsupp" ps,
14
- "tpch"."tiny"."nation" n,
15
- "tpch"."tiny"."region" r
16
- WHERE
17
- p.partkey = ps.partkey
18
- AND s.suppkey = ps.suppkey
19
- AND p.size = 15
20
- AND p.type like '%BRASS'
21
- AND s.nationkey = n.nationkey
22
- AND n.regionkey = r.regionkey
23
- AND r.name = 'EUROPE'
24
- AND ps.supplycost = (
25
- SELECT
26
- min(ps.supplycost)
27
- FROM
28
- "tpch"."tiny"."partsupp" ps,
29
- "tpch"."tiny"."supplier" s,
30
- "tpch"."tiny"."nation" n,
31
- "tpch"."tiny"."region" r
32
- WHERE
33
- p.partkey = ps.partkey
34
- AND s.suppkey = ps.suppkey
35
- AND s.nationkey = n.nationkey
36
- AND n.regionkey = r.regionkey
37
- AND r.name = 'EUROPE'
38
- )
39
- ORDER BY
40
- s.acctbal desc,
41
- n.name,
42
- s.name,
43
- p.partkey