-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add all tpch queries to sqllogictest (#253)
Also updated #184
- Loading branch information
Showing
22 changed files
with
849 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
include _tpch_tables.slt.part | ||
|
||
query | ||
select | ||
c_custkey, | ||
c_name, | ||
sum(l_extendedprice * (1 - l_discount)) as revenue, | ||
c_acctbal, | ||
n_name, | ||
c_address, | ||
c_phone, | ||
c_comment | ||
from | ||
customer, | ||
orders, | ||
lineitem, | ||
nation | ||
where | ||
c_custkey = o_custkey | ||
and l_orderkey = o_orderkey | ||
and o_orderdate >= date '1993-10-01' | ||
and o_orderdate < date '1993-10-01' + interval '3' month | ||
and l_returnflag = 'R' | ||
and c_nationkey = n_nationkey | ||
group by | ||
c_custkey, | ||
c_name, | ||
c_acctbal, | ||
c_phone, | ||
n_name, | ||
c_address, | ||
c_comment | ||
order by | ||
revenue desc | ||
limit 20; | ||
---- | ||
121 Customer#000000121 282635.1719 6428.32 PERU tv nCR2YKupGN73mQudO 27-411-990-2959 uriously stealthy ideas. carefully final courts use carefully | ||
124 Customer#000000124 222182.5188 1842.49 CHINA aTbyVAW5tCd,v09O 28-183-750-7809 le fluffily even dependencies. quietly s | ||
106 Customer#000000106 190241.3334 3288.42 ARGENTINA xGCOEAUjUNG 11-751-989-4627 lose slyly. ironic accounts along the evenly regular theodolites wake about the special, final gifts. | ||
16 Customer#000000016 161422.0461 4681.03 IRAN cYiaeMLZSMAOQ2 d0W, 20-781-609-3107 kly silent courts. thinly regular theodolites sleep fluffily after | ||
44 Customer#000000044 149364.5652 7315.94 MOZAMBIQUE Oi,dOSPwDu4jo4x,,P85E0dmhZGvNtBwi 26-190-260-5375 r requests around the unusual, bold a | ||
71 Customer#000000071 129481.0245 -611.19 GERMANY TlGalgdXWBmMV,6agLyWYDyIz9MKzcY8gl,w6t1B 17-710-812-5403 g courts across the regular, final pinto beans are blithely pending ac | ||
89 Customer#000000089 121663.1243 1530.76 KENYA dtR, y9JQWUO6FoJExyp8whOU 24-394-451-5404 counts are slyly beyond the slyly final accounts. quickly final ideas wake. r | ||
112 Customer#000000112 111137.7141 2953.35 ROMANIA RcfgG3bO7QeCnfjqJT1 29-233-262-8382 rmanently unusual multipliers. blithely ruthless deposits are furiously along the | ||
62 Customer#000000062 106368.0153 595.61 GERMANY upJK2Dnw13, 17-361-978-7059 kly special dolphins. pinto beans are slyly. quickly regular accounts are furiously a | ||
146 Customer#000000146 103265.9888 3328.68 CANADA GdxkdXG9u7iyI1,,y5tq4ZyrcEy 13-835-723-3223 ffily regular dinos are slyly unusual requests. slyly specia | ||
19 Customer#000000019 99306.0127 8914.71 CHINA uc,3bHIx84H,wdrmLOjVsiqXCq2tr 28-396-526-5053 nag. furiously careful packages are slyly at the accounts. furiously regular in | ||
145 Customer#000000145 99256.9018 9748.93 JORDAN kQjHmt2kcec cy3hfMh969u 23-562-444-8454 ests? express, express instructions use. blithely fina | ||
103 Customer#000000103 97311.7724 2757.45 INDONESIA 8KIsQX4LJ7QMsj6DrtFtXu0nUEdV,8a 19-216-107-2107 furiously pending notornis boost slyly around the blithely ironic ideas? final, even instructions cajole fl | ||
136 Customer#000000136 95855.3980 -842.39 GERMANY QoLsJ0v5C1IQbh,DS1 17-501-210-4726 ackages sleep ironic, final courts. even requests above the blithely bold requests g | ||
53 Customer#000000053 92568.9124 4113.64 MOROCCO HnaxHzTfFTZs8MuCpJyTbZ47Cm4wFOOgib 25-168-852-5363 ar accounts are. even foxes are blithely. fluffily pending deposits boost | ||
49 Customer#000000049 90965.7262 4573.94 IRAN cNgAeX7Fqrdf7HQN9EwjUa4nxT,68L FKAxzl 20-908-631-4424 nusual foxes! fluffily pending packages maintain to the regular | ||
37 Customer#000000037 88065.7458 -917.75 INDIA 7EV4Pwh,3SboctTWt 18-385-235-7162 ilent packages are carefully among the deposits. furiousl | ||
82 Customer#000000082 86998.9644 9468.34 CHINA zhG3EZbap4c992Gj3bK,3Ne,Xn 28-159-442-5305 s wake. bravely regular accounts are furiously. regula | ||
125 Customer#000000125 84808.0680 -234.12 ROMANIA ,wSZXdVR xxIIfm9s8ITyLl3kgjT6UC07GY0Y 29-261-996-3120 x-ray finally after the packages? regular requests c | ||
59 Customer#000000059 84655.5711 3458.60 ARGENTINA zLOCP0wh92OtBihgspOGl4 11-355-584-3112 ously final packages haggle blithely after the express deposits. furiou |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
include _tpch_tables.slt.part | ||
|
||
query | ||
select | ||
ps_partkey, | ||
sum(ps_supplycost * ps_availqty) as value | ||
from | ||
partsupp, | ||
supplier, | ||
nation | ||
where | ||
ps_suppkey = s_suppkey | ||
and s_nationkey = n_nationkey | ||
and n_name = 'GERMANY' | ||
group by | ||
ps_partkey having | ||
sum(ps_supplycost * ps_availqty) > ( | ||
select | ||
sum(ps_supplycost * ps_availqty) * 0.0001000000 | ||
from | ||
partsupp, | ||
supplier, | ||
nation | ||
where | ||
ps_suppkey = s_suppkey | ||
and s_nationkey = n_nationkey | ||
and n_name = 'GERMANY' | ||
) | ||
order by | ||
value desc; | ||
---- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
include _tpch_tables.slt.part | ||
|
||
query | ||
select | ||
l_shipmode, | ||
sum(case | ||
when o_orderpriority = '1-URGENT' | ||
or o_orderpriority = '2-HIGH' | ||
then 1 | ||
else 0 | ||
end) as high_line_count, | ||
sum(case | ||
when o_orderpriority <> '1-URGENT' | ||
and o_orderpriority <> '2-HIGH' | ||
then 1 | ||
else 0 | ||
end) as low_line_count | ||
from | ||
orders, | ||
lineitem | ||
where | ||
o_orderkey = l_orderkey | ||
and l_shipmode in ('MAIL', 'SHIP') | ||
and l_commitdate < l_receiptdate | ||
and l_shipdate < l_commitdate | ||
and l_receiptdate >= date '1994-01-01' | ||
and l_receiptdate < date '1994-01-01' + interval '1' year | ||
group by | ||
l_shipmode | ||
order by | ||
l_shipmode; | ||
---- | ||
MAIL 5 5 | ||
SHIP 5 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
include _tpch_tables.slt.part | ||
|
||
query | ||
select | ||
c_count, | ||
count(*) as custdist | ||
from | ||
( | ||
select | ||
c_custkey, | ||
count(o_orderkey) | ||
from | ||
customer left outer join orders on | ||
c_custkey = o_custkey | ||
and o_comment not like '%special%requests%' | ||
group by | ||
c_custkey | ||
) as c_orders (c_custkey, c_count) | ||
group by | ||
c_count | ||
order by | ||
custdist desc, | ||
c_count desc; | ||
---- | ||
0 50 | ||
16 8 | ||
17 7 | ||
20 6 | ||
13 6 | ||
12 6 | ||
9 6 | ||
23 5 | ||
14 5 | ||
10 5 | ||
21 4 | ||
18 4 | ||
11 4 | ||
8 4 | ||
7 4 | ||
26 3 | ||
22 3 | ||
6 3 | ||
5 3 | ||
4 3 | ||
29 2 | ||
24 2 | ||
19 2 | ||
15 2 | ||
28 1 | ||
25 1 | ||
3 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
include _tpch_tables.slt.part | ||
|
||
query | ||
select | ||
100.00 * sum(case | ||
when p_type like 'PROMO%' | ||
then l_extendedprice * (1 - l_discount) | ||
else 0 | ||
end) / sum(l_extendedprice * (1 - l_discount)) as promo_revenue | ||
from | ||
lineitem, | ||
part | ||
where | ||
l_partkey = p_partkey | ||
and l_shipdate >= date '1995-09-01' | ||
and l_shipdate < date '1995-09-01' + interval '1' month; | ||
---- | ||
15.23021261159725 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
include _tpch_tables.slt.part | ||
|
||
statement ok | ||
create view revenue0 (supplier_no, total_revenue) as | ||
select | ||
l_suppkey, | ||
sum(l_extendedprice * (1 - l_discount)) | ||
from | ||
lineitem | ||
where | ||
l_shipdate >= date '1996-01-01' | ||
and l_shipdate < date '1996-01-01' + interval '3' month | ||
group by | ||
l_suppkey; | ||
|
||
query | ||
select | ||
s_suppkey, | ||
s_name, | ||
s_address, | ||
s_phone, | ||
total_revenue | ||
from | ||
supplier, | ||
revenue0 | ||
where | ||
s_suppkey = supplier_no | ||
and total_revenue = ( | ||
select | ||
max(total_revenue) | ||
from | ||
revenue0 | ||
) | ||
order by | ||
s_suppkey; | ||
---- | ||
10 Supplier#000000010 Saygah3gYWMp72i PY 34-852-489-8585 797313.3838 | ||
|
||
statement ok | ||
drop view revenue0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
include _tpch_tables.slt.part | ||
|
||
query | ||
select | ||
p_brand, | ||
p_type, | ||
p_size, | ||
count(distinct ps_suppkey) as supplier_cnt | ||
from | ||
partsupp, | ||
part | ||
where | ||
p_partkey = ps_partkey | ||
and p_brand <> 'Brand#45' | ||
and p_type not like 'MEDIUM POLISHED%' | ||
and p_size in (49, 14, 23, 45, 19, 3, 36, 9) | ||
and ps_suppkey not in ( | ||
select | ||
s_suppkey | ||
from | ||
supplier | ||
where | ||
s_comment like '%Customer%Complaints%' | ||
) | ||
group by | ||
p_brand, | ||
p_type, | ||
p_size | ||
order by | ||
supplier_cnt desc, | ||
p_brand, | ||
p_type, | ||
p_size; | ||
---- | ||
Brand#11 PROMO ANODIZED TIN 45 4 | ||
Brand#11 SMALL PLATED COPPER 45 4 | ||
Brand#11 STANDARD POLISHED TIN 45 4 | ||
Brand#13 MEDIUM ANODIZED STEEL 36 4 | ||
Brand#14 SMALL ANODIZED NICKEL 45 4 | ||
Brand#15 LARGE ANODIZED BRASS 45 4 | ||
Brand#21 LARGE BURNISHED COPPER 19 4 | ||
Brand#23 ECONOMY BRUSHED COPPER 9 4 | ||
Brand#25 MEDIUM PLATED BRASS 45 4 | ||
Brand#31 ECONOMY PLATED STEEL 23 4 | ||
Brand#31 PROMO POLISHED TIN 23 4 | ||
Brand#32 MEDIUM BURNISHED BRASS 49 4 | ||
Brand#33 LARGE BRUSHED TIN 36 4 | ||
Brand#33 SMALL BURNISHED NICKEL 3 4 | ||
Brand#34 LARGE PLATED BRASS 45 4 | ||
Brand#34 MEDIUM BRUSHED COPPER 9 4 | ||
Brand#34 SMALL PLATED BRASS 14 4 | ||
Brand#35 STANDARD ANODIZED STEEL 23 4 | ||
Brand#43 PROMO POLISHED BRASS 19 4 | ||
Brand#43 SMALL BRUSHED NICKEL 9 4 | ||
Brand#44 SMALL PLATED COPPER 19 4 | ||
Brand#52 MEDIUM BURNISHED TIN 45 4 | ||
Brand#52 SMALL BURNISHED NICKEL 14 4 | ||
Brand#53 MEDIUM BRUSHED COPPER 3 4 | ||
Brand#55 STANDARD ANODIZED BRASS 36 4 | ||
Brand#55 STANDARD BRUSHED COPPER 3 4 | ||
Brand#13 SMALL BRUSHED NICKEL 19 2 | ||
Brand#25 SMALL BURNISHED COPPER 3 2 | ||
Brand#43 MEDIUM ANODIZED BRASS 14 2 | ||
Brand#53 STANDARD PLATED STEEL 45 2 | ||
Brand#24 MEDIUM PLATED STEEL 19 1 | ||
Brand#51 ECONOMY POLISHED STEEL 49 1 | ||
Brand#53 LARGE BURNISHED NICKEL 23 1 | ||
Brand#54 ECONOMY ANODIZED BRASS 9 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
include _tpch_tables.slt.part | ||
|
||
query | ||
select | ||
sum(l_extendedprice) / 7.0 as avg_yearly | ||
from | ||
lineitem, | ||
part | ||
where | ||
p_partkey = l_partkey | ||
and p_brand = 'Brand#53' -- original: Brand#23 | ||
and p_container = 'MED BOX' | ||
and l_quantity < ( | ||
select | ||
0.2 * avg(l_quantity) | ||
from | ||
lineitem | ||
where | ||
l_partkey = p_partkey | ||
); | ||
---- | ||
863.2285714285714285714285714 |
Oops, something went wrong.