Skip to content

Commit 6512437

Browse files
authored
Test sort merge join on TPC-H benchmark (#13572)
* Test merge join * Add files
1 parent eca0e07 commit 6512437

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1250
-902
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
19+
query TTRRRRRRRI
20+
select
21+
l_returnflag,
22+
l_linestatus,
23+
sum(l_quantity) as sum_qty,
24+
sum(l_extendedprice) as sum_base_price,
25+
sum(l_extendedprice * (1 - l_discount)) as sum_disc_price,
26+
sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) as sum_charge,
27+
avg(l_quantity) as avg_qty,
28+
avg(l_extendedprice) as avg_price,
29+
avg(l_discount) as avg_disc,
30+
count(*) as count_order
31+
from
32+
lineitem
33+
where
34+
l_shipdate <= date '1998-09-02'
35+
group by
36+
l_returnflag,
37+
l_linestatus
38+
order by
39+
l_returnflag,
40+
l_linestatus;
41+
----
42+
A F 3774200 5320753880.69 5054096266.6828 5256751331.449234 25.537587 36002.123829 0.050144 147790
43+
N F 95257 133737795.84 127132372.6512 132286291.229445 25.300664 35521.326916 0.049394 3765
44+
N O 7459297 10512270008.9 9986238338.3847 10385578376.585467 25.545537 36000.924688 0.050095 292000
45+
R F 3785523 5337950526.47 5071818532.942 5274405503.049367 25.525943 35994.029214 0.049989 148301
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
19+
query ITRRTTTT
20+
select
21+
c_custkey,
22+
c_name,
23+
sum(l_extendedprice * (1 - l_discount)) as revenue,
24+
c_acctbal,
25+
n_name,
26+
c_address,
27+
c_phone,
28+
c_comment
29+
from
30+
customer,
31+
orders,
32+
lineitem,
33+
nation
34+
where
35+
c_custkey = o_custkey
36+
and l_orderkey = o_orderkey
37+
and o_orderdate >= date '1993-10-01'
38+
and o_orderdate < date '1994-01-01'
39+
and l_returnflag = 'R'
40+
and c_nationkey = n_nationkey
41+
group by
42+
c_custkey,
43+
c_name,
44+
c_acctbal,
45+
c_phone,
46+
n_name,
47+
c_address,
48+
c_comment
49+
order by
50+
revenue desc
51+
limit 10;
52+
----
53+
8242 Customer#000008242 622786.7297 6322.09 ETHIOPIA P2n4nJhy,UqSo2s43YfSvYJDZ6lk 15-792-676-1184 slyly regular packages haggle carefully ironic ideas. courts are furiously. furiously unusual theodolites cajole. i
54+
7714 Customer#000007714 557400.3053 9799.98 IRAN SnnIGB,SkmnWpX3 20-922-418-6024 arhorses according to the blithely express re
55+
11032 Customer#000011032 512500.9641 8496.93 UNITED KINGDOM WIKHC7K3Cn7156iNOyfVG3cZ7YqkgsR,Ly 33-102-772-3533 posits-- furiously ironic accounts are again
56+
2455 Customer#000002455 481592.4053 2070.99 GERMANY RVn1ZSRtLqPlJLIZxvpmsbgC02 17-946-225-9977 al asymptotes. finally ironic accounts cajole furiously. permanently unusual theodolites aro
57+
12106 Customer#000012106 479414.2133 5342.11 UNITED STATES wth3twOmu6vy 34-905-346-4472 ly after the blithely regular foxes. accounts haggle carefully alongside of the blithely even ideas.
58+
8530 Customer#000008530 457855.9467 9734.95 MOROCCO GMQyte94oDM7eD7exnkj 4hH9yq3 25-736-932-5850 slyly asymptotes. quickly final deposits in
59+
13984 Customer#000013984 446316.5104 3482.28 IRAN qZXwuapCHvxbX 20-981-264-2952 y unusual courts could wake furiously
60+
1966 Customer#000001966 444059.0382 1937.72 ALGERIA jPv1 UHra5JLALR5Isci5u0636RoAu7t vH 10-973-269-8886 the blithely even accounts. final deposits cajole around the blithely final packages.
61+
11026 Customer#000011026 417913.4142 7738.76 ALGERIA XorIktoJOAEJkpNNMx 10-184-163-4632 ly even dolphins eat along the blithely even instructions. express attainments cajole slyly. busy dolphins in
62+
8501 Customer#000008501 412797.51 6906.7 ARGENTINA 776af4rOa mZ66hczs 11-317-552-5840 y final deposits after the fluffily even accounts are slyly final, regular
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
19+
query IR
20+
select
21+
ps_partkey,
22+
sum(ps_supplycost * ps_availqty) as value
23+
from
24+
partsupp,
25+
supplier,
26+
nation
27+
where
28+
ps_suppkey = s_suppkey
29+
and s_nationkey = n_nationkey
30+
and n_name = 'GERMANY'
31+
group by
32+
ps_partkey having
33+
sum(ps_supplycost * ps_availqty) > (
34+
select
35+
sum(ps_supplycost * ps_availqty) * 0.0001
36+
from
37+
partsupp,
38+
supplier,
39+
nation
40+
where
41+
ps_suppkey = s_suppkey
42+
and s_nationkey = n_nationkey
43+
and n_name = 'GERMANY'
44+
)
45+
order by
46+
value desc
47+
limit 10;
48+
----
49+
12098 16227681.21
50+
5134 15709338.52
51+
13334 15023662.41
52+
17052 14351644.2
53+
3452 14070870.14
54+
12552 13332469.18
55+
1084 13170428.29
56+
5797 13038622.72
57+
12633 12892561.61
58+
403 12856217.34
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
19+
query TII
20+
select
21+
l_shipmode,
22+
sum(case
23+
when o_orderpriority = '1-URGENT'
24+
or o_orderpriority = '2-HIGH'
25+
then 1
26+
else 0
27+
end) as high_line_count,
28+
sum(case
29+
when o_orderpriority <> '1-URGENT'
30+
and o_orderpriority <> '2-HIGH'
31+
then 1
32+
else 0
33+
end) as low_line_count
34+
from
35+
lineitem
36+
join
37+
orders
38+
on
39+
l_orderkey = o_orderkey
40+
where
41+
l_shipmode in ('MAIL', 'SHIP')
42+
and l_commitdate < l_receiptdate
43+
and l_shipdate < l_commitdate
44+
and l_receiptdate >= date '1994-01-01'
45+
and l_receiptdate < date '1995-01-01'
46+
group by
47+
l_shipmode
48+
order by
49+
l_shipmode;
50+
----
51+
MAIL 647 945
52+
SHIP 620 943
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
19+
query II
20+
select
21+
c_count,
22+
count(*) as custdist
23+
from
24+
(
25+
select
26+
c_custkey,
27+
count(o_orderkey)
28+
from
29+
customer left outer join orders on
30+
c_custkey = o_custkey
31+
and o_comment not like '%special%requests%'
32+
group by
33+
c_custkey
34+
) as c_orders (c_custkey, c_count)
35+
group by
36+
c_count
37+
order by
38+
custdist desc,
39+
c_count desc
40+
limit 10;
41+
----
42+
0 5000
43+
10 665
44+
9 657
45+
11 621
46+
12 567
47+
8 564
48+
13 492
49+
18 482
50+
7 480
51+
20 456
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
19+
query R
20+
select
21+
100.00 * sum(case
22+
when p_type like 'PROMO%'
23+
then l_extendedprice * (1 - l_discount)
24+
else 0
25+
end) / sum(l_extendedprice * (1 - l_discount)) as promo_revenue
26+
from
27+
lineitem,
28+
part
29+
where
30+
l_partkey = p_partkey
31+
and l_shipdate >= date '1995-09-01'
32+
and l_shipdate < date '1995-10-01';
33+
----
34+
16.283855689006
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
19+
query ITTTR
20+
with revenue0 (supplier_no, total_revenue) as (
21+
select
22+
l_suppkey,
23+
sum(l_extendedprice * (1 - l_discount))
24+
from
25+
lineitem
26+
where
27+
l_shipdate >= date '1996-01-01'
28+
and l_shipdate < date '1996-01-01' + interval '3' month
29+
group by
30+
l_suppkey
31+
)
32+
select
33+
s_suppkey,
34+
s_name,
35+
s_address,
36+
s_phone,
37+
total_revenue
38+
from
39+
supplier,
40+
revenue0
41+
where
42+
s_suppkey = supplier_no
43+
and total_revenue = (
44+
select
45+
max(total_revenue)
46+
from
47+
revenue0
48+
)
49+
order by
50+
s_suppkey;
51+
----
52+
677 Supplier#000000677 8mhrffG7D2WJBSQbOGstQ 23-290-639-3315 1614410.2928

0 commit comments

Comments
 (0)