Skip to content

Commit 5cab189

Browse files
authored
Add TPCH reggression tests (apache#221)
* Add TPC-H reggression tests
1 parent f3b9edc commit 5cab189

23 files changed

Lines changed: 738 additions & 0 deletions

tests/queries/tpch/1.sql

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
lineitem
14+
where
15+
l_shipdate <= date '1998-12-01' - interval '90' day (3)
16+
group by
17+
l_returnflag,
18+
l_linestatus
19+
order by
20+
l_returnflag,
21+
l_linestatus;

tests/queries/tpch/10.sql

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
-- using default substitutions
2+
3+
4+
select
5+
c_custkey,
6+
c_name,
7+
sum(l_extendedprice * (1 - l_discount)) as revenue,
8+
c_acctbal,
9+
n_name,
10+
c_address,
11+
c_phone,
12+
c_comment
13+
from
14+
customer,
15+
orders,
16+
lineitem,
17+
nation
18+
where
19+
c_custkey = o_custkey
20+
and l_orderkey = o_orderkey
21+
and o_orderdate >= date '1993-10-01'
22+
and o_orderdate < date '1993-10-01' + interval '3' month
23+
and l_returnflag = 'R'
24+
and c_nationkey = n_nationkey
25+
group by
26+
c_custkey,
27+
c_name,
28+
c_acctbal,
29+
c_phone,
30+
n_name,
31+
c_address,
32+
c_comment
33+
order by
34+
revenue desc;

tests/queries/tpch/11.sql

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
-- using default substitutions
2+
3+
4+
select
5+
ps_partkey,
6+
sum(ps_supplycost * ps_availqty) as value
7+
from
8+
partsupp,
9+
supplier,
10+
nation
11+
where
12+
ps_suppkey = s_suppkey
13+
and s_nationkey = n_nationkey
14+
and n_name = 'GERMANY'
15+
group by
16+
ps_partkey having
17+
sum(ps_supplycost * ps_availqty) > (
18+
select
19+
sum(ps_supplycost * ps_availqty) * 0.0001000000
20+
from
21+
partsupp,
22+
supplier,
23+
nation
24+
where
25+
ps_suppkey = s_suppkey
26+
and s_nationkey = n_nationkey
27+
and n_name = 'GERMANY'
28+
)
29+
order by
30+
value desc;

tests/queries/tpch/12.sql

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
-- using default substitutions
2+
3+
4+
select
5+
l_shipmode,
6+
sum(case
7+
when o_orderpriority = '1-URGENT'
8+
or o_orderpriority = '2-HIGH'
9+
then 1
10+
else 0
11+
end) as high_line_count,
12+
sum(case
13+
when o_orderpriority <> '1-URGENT'
14+
and o_orderpriority <> '2-HIGH'
15+
then 1
16+
else 0
17+
end) as low_line_count
18+
from
19+
orders,
20+
lineitem
21+
where
22+
o_orderkey = l_orderkey
23+
and l_shipmode in ('MAIL', 'SHIP')
24+
and l_commitdate < l_receiptdate
25+
and l_shipdate < l_commitdate
26+
and l_receiptdate >= date '1994-01-01'
27+
and l_receiptdate < date '1994-01-01' + interval '1' year
28+
group by
29+
l_shipmode
30+
order by
31+
l_shipmode;

tests/queries/tpch/13.sql

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
-- using default substitutions
2+
3+
4+
select
5+
c_count,
6+
count(*) as custdist
7+
from
8+
(
9+
select
10+
c_custkey,
11+
count(o_orderkey)
12+
from
13+
customer left outer join orders on
14+
c_custkey = o_custkey
15+
and o_comment not like '%special%requests%'
16+
group by
17+
c_custkey
18+
) as c_orders (c_custkey, c_count)
19+
group by
20+
c_count
21+
order by
22+
custdist desc,
23+
c_count desc;

tests/queries/tpch/14.sql

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-- using default substitutions
2+
3+
4+
select
5+
100.00 * sum(case
6+
when p_type like 'PROMO%'
7+
then l_extendedprice * (1 - l_discount)
8+
else 0
9+
end) / sum(l_extendedprice * (1 - l_discount)) as promo_revenue
10+
from
11+
lineitem,
12+
part
13+
where
14+
l_partkey = p_partkey
15+
and l_shipdate >= date '1995-09-01'
16+
and l_shipdate < date '1995-09-01' + interval '1' month;

tests/queries/tpch/15.sql

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
-- using default substitutions
2+
3+
create view revenue0 (supplier_no, total_revenue) as
4+
select
5+
l_suppkey,
6+
sum(l_extendedprice * (1 - l_discount))
7+
from
8+
lineitem
9+
where
10+
l_shipdate >= date '1996-01-01'
11+
and l_shipdate < date '1996-01-01' + interval '3' month
12+
group by
13+
l_suppkey;
14+
15+
16+
select
17+
s_suppkey,
18+
s_name,
19+
s_address,
20+
s_phone,
21+
total_revenue
22+
from
23+
supplier,
24+
revenue0
25+
where
26+
s_suppkey = supplier_no
27+
and total_revenue = (
28+
select
29+
max(total_revenue)
30+
from
31+
revenue0
32+
)
33+
order by
34+
s_suppkey;
35+
36+
drop view revenue0;

tests/queries/tpch/16.sql

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
-- using default substitutions
2+
3+
4+
select
5+
p_brand,
6+
p_type,
7+
p_size,
8+
count(distinct ps_suppkey) as supplier_cnt
9+
from
10+
partsupp,
11+
part
12+
where
13+
p_partkey = ps_partkey
14+
and p_brand <> 'Brand#45'
15+
and p_type not like 'MEDIUM POLISHED%'
16+
and p_size in (49, 14, 23, 45, 19, 3, 36, 9)
17+
and ps_suppkey not in (
18+
select
19+
s_suppkey
20+
from
21+
supplier
22+
where
23+
s_comment like '%Customer%Complaints%'
24+
)
25+
group by
26+
p_brand,
27+
p_type,
28+
p_size
29+
order by
30+
supplier_cnt desc,
31+
p_brand,
32+
p_type,
33+
p_size;

tests/queries/tpch/17.sql

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
-- using default substitutions
2+
3+
4+
select
5+
sum(l_extendedprice) / 7.0 as avg_yearly
6+
from
7+
lineitem,
8+
part
9+
where
10+
p_partkey = l_partkey
11+
and p_brand = 'Brand#23'
12+
and p_container = 'MED BOX'
13+
and l_quantity < (
14+
select
15+
0.2 * avg(l_quantity)
16+
from
17+
lineitem
18+
where
19+
l_partkey = p_partkey
20+
);

tests/queries/tpch/18.sql

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
-- using default substitutions
2+
3+
4+
select
5+
c_name,
6+
c_custkey,
7+
o_orderkey,
8+
o_orderdate,
9+
o_totalprice,
10+
sum(l_quantity)
11+
from
12+
customer,
13+
orders,
14+
lineitem
15+
where
16+
o_orderkey in (
17+
select
18+
l_orderkey
19+
from
20+
lineitem
21+
group by
22+
l_orderkey having
23+
sum(l_quantity) > 300
24+
)
25+
and c_custkey = o_custkey
26+
and o_orderkey = l_orderkey
27+
group by
28+
c_name,
29+
c_custkey,
30+
o_orderkey,
31+
o_orderdate,
32+
o_totalprice
33+
order by
34+
o_totalprice desc,
35+
o_orderdate;

0 commit comments

Comments
 (0)