Skip to content

Commit 707a018

Browse files
Add remaining tpch queries
1 parent 7626eee commit 707a018

File tree

1 file changed

+115
-17
lines changed

1 file changed

+115
-17
lines changed

datafusion/core/benches/sql_planner.rs

Lines changed: 115 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,16 @@ pub fn create_table_provider(column_prefix: &str, num_columns: usize) -> Arc<Mem
6060
MemTable::try_new(schema, vec![]).map(Arc::new).unwrap()
6161
}
6262

63-
pub fn create_tpch_schemas() -> [(String, Schema); 2] {
63+
pub fn create_tpch_schemas() -> [(String, Schema); 8] {
6464
let lineitem_schema = Schema::new(vec![
65-
Field::new("l_orderkey", DataType::Int32, false),
66-
Field::new("l_partkey", DataType::Int32, false),
67-
Field::new("l_suppkey", DataType::Int32, false),
65+
Field::new("l_orderkey", DataType::Int64, false),
66+
Field::new("l_partkey", DataType::Int64, false),
67+
Field::new("l_suppkey", DataType::Int64, false),
6868
Field::new("l_linenumber", DataType::Int32, false),
69-
Field::new("l_quantity", DataType::Float64, false),
70-
Field::new("l_extendedprice", DataType::Float64, false),
71-
Field::new("l_discount", DataType::Float64, false),
72-
Field::new("l_tax", DataType::Float64, false),
69+
Field::new("l_quantity", DataType::Decimal128(15, 2), false),
70+
Field::new("l_extendedprice", DataType::Decimal128(15, 2), false),
71+
Field::new("l_discount", DataType::Decimal128(15, 2), false),
72+
Field::new("l_tax", DataType::Decimal128(15, 2), false),
7373
Field::new("l_returnflag", DataType::Utf8, false),
7474
Field::new("l_linestatus", DataType::Utf8, false),
7575
Field::new("l_shipdate", DataType::Date32, false),
@@ -81,20 +81,80 @@ pub fn create_tpch_schemas() -> [(String, Schema); 2] {
8181
]);
8282

8383
let orders_schema = Schema::new(vec![
84-
Field::new("o_orderkey", DataType::Int32, false),
85-
Field::new("o_custkey", DataType::Int32, false),
84+
Field::new("o_orderkey", DataType::Int64, false),
85+
Field::new("o_custkey", DataType::Int64, false),
8686
Field::new("o_orderstatus", DataType::Utf8, false),
87-
Field::new("o_totalprice", DataType::Float64, false),
87+
Field::new("o_totalprice", DataType::Decimal128(15, 2), false),
8888
Field::new("o_orderdate", DataType::Date32, false),
8989
Field::new("o_orderpriority", DataType::Utf8, false),
9090
Field::new("o_clerk", DataType::Utf8, false),
9191
Field::new("o_shippriority", DataType::Int32, false),
9292
Field::new("o_comment", DataType::Utf8, false),
9393
]);
9494

95+
let part_schema = Schema::new(vec![
96+
Field::new("p_partkey", DataType::Int64, false),
97+
Field::new("p_name", DataType::Utf8, false),
98+
Field::new("p_mfgr", DataType::Utf8, false),
99+
Field::new("p_brand", DataType::Utf8, false),
100+
Field::new("p_type", DataType::Utf8, false),
101+
Field::new("p_size", DataType::Int32, false),
102+
Field::new("p_container", DataType::Utf8, false),
103+
Field::new("p_retailprice", DataType::Decimal128(15, 2), false),
104+
Field::new("p_comment", DataType::Utf8, false),
105+
]);
106+
107+
let supplier_schema = Schema::new(vec![
108+
Field::new("s_suppkey", DataType::Int64, false),
109+
Field::new("s_name", DataType::Utf8, false),
110+
Field::new("s_address", DataType::Utf8, false),
111+
Field::new("s_nationkey", DataType::Int64, false),
112+
Field::new("s_phone", DataType::Utf8, false),
113+
Field::new("s_acctbal", DataType::Decimal128(15, 2), false),
114+
Field::new("s_comment", DataType::Utf8, false),
115+
]);
116+
117+
let partsupp_schema = Schema::new(vec![
118+
Field::new("ps_partkey", DataType::Int64, false),
119+
Field::new("ps_suppkey", DataType::Int64, false),
120+
Field::new("ps_availqty", DataType::Int32, false),
121+
Field::new("ps_supplycost", DataType::Decimal128(15, 2), false),
122+
Field::new("ps_comment", DataType::Utf8, false),
123+
]);
124+
125+
let customer_schema = Schema::new(vec![
126+
Field::new("c_custkey", DataType::Int64, false),
127+
Field::new("c_name", DataType::Utf8, false),
128+
Field::new("c_address", DataType::Utf8, false),
129+
Field::new("c_nationkey", DataType::Int64, false),
130+
Field::new("c_phone", DataType::Utf8, false),
131+
Field::new("c_acctbal", DataType::Decimal128(15, 2), false),
132+
Field::new("c_mktsegment", DataType::Utf8, false),
133+
Field::new("c_comment", DataType::Utf8, false),
134+
]);
135+
136+
let nation_schema = Schema::new(vec![
137+
Field::new("n_nationkey", DataType::Int64, false),
138+
Field::new("n_name", DataType::Utf8, false),
139+
Field::new("n_regionkey", DataType::Int64, false),
140+
Field::new("n_comment", DataType::Utf8, false),
141+
]);
142+
143+
let region_schema = Schema::new(vec![
144+
Field::new("r_regionkey", DataType::Int64, false),
145+
Field::new("r_name", DataType::Utf8, false),
146+
Field::new("r_comment", DataType::Utf8, false),
147+
]);
148+
95149
return [
96150
("lineitem".to_string(), lineitem_schema),
97151
("orders".to_string(), orders_schema),
152+
("part".to_string(), part_schema),
153+
("supplier".to_string(), supplier_schema),
154+
("partsupp".to_string(), partsupp_schema),
155+
("customer".to_string(), customer_schema),
156+
("nation".to_string(), nation_schema),
157+
("region".to_string(), region_schema),
98158
];
99159
}
100160

@@ -165,13 +225,51 @@ fn criterion_benchmark(c: &mut Criterion) {
165225
});
166226

167227
let q1_sql = std::fs::read_to_string("../../benchmarks/queries/q1.sql").unwrap();
168-
c.bench_function("physical_plan_tpch_q1", |b| {
169-
b.iter(|| physical_plan(&ctx, &q1_sql))
170-
});
171-
228+
let q2_sql = std::fs::read_to_string("../../benchmarks/queries/q2.sql").unwrap();
229+
let q3_sql = std::fs::read_to_string("../../benchmarks/queries/q3.sql").unwrap();
230+
let q4_sql = std::fs::read_to_string("../../benchmarks/queries/q4.sql").unwrap();
231+
let q5_sql = std::fs::read_to_string("../../benchmarks/queries/q5.sql").unwrap();
232+
let q6_sql = std::fs::read_to_string("../../benchmarks/queries/q6.sql").unwrap();
233+
let q7_sql = std::fs::read_to_string("../../benchmarks/queries/q7.sql").unwrap();
234+
let q8_sql = std::fs::read_to_string("../../benchmarks/queries/q8.sql").unwrap();
235+
let q9_sql = std::fs::read_to_string("../../benchmarks/queries/q9.sql").unwrap();
236+
let q10_sql = std::fs::read_to_string("../../benchmarks/queries/q10.sql").unwrap();
237+
let q11_sql = std::fs::read_to_string("../../benchmarks/queries/q11.sql").unwrap();
172238
let q12_sql = std::fs::read_to_string("../../benchmarks/queries/q12.sql").unwrap();
173-
c.bench_function("physical_plan_tpch_q12", |b| {
174-
b.iter(|| physical_plan(&ctx, &q12_sql))
239+
let q13_sql = std::fs::read_to_string("../../benchmarks/queries/q13.sql").unwrap();
240+
let q14_sql = std::fs::read_to_string("../../benchmarks/queries/q14.sql").unwrap();
241+
// let q15_sql = std::fs::read_to_string("../../benchmarks/queries/q15.sql").unwrap();
242+
let q16_sql = std::fs::read_to_string("../../benchmarks/queries/q16.sql").unwrap();
243+
let q17_sql = std::fs::read_to_string("../../benchmarks/queries/q17.sql").unwrap();
244+
let q18_sql = std::fs::read_to_string("../../benchmarks/queries/q18.sql").unwrap();
245+
let q19_sql = std::fs::read_to_string("../../benchmarks/queries/q19.sql").unwrap();
246+
let q20_sql = std::fs::read_to_string("../../benchmarks/queries/q20.sql").unwrap();
247+
let q21_sql = std::fs::read_to_string("../../benchmarks/queries/q21.sql").unwrap();
248+
let q22_sql = std::fs::read_to_string("../../benchmarks/queries/q22.sql").unwrap();
249+
250+
c.bench("physical_plan_tpch", |b| {
251+
b.iter(|| physical_plan(&ctx, &q1_sql));
252+
b.iter(|| physical_plan(&ctx, &q2_sql));
253+
b.iter(|| physical_plan(&ctx, &q3_sql));
254+
b.iter(|| physical_plan(&ctx, &q4_sql));
255+
b.iter(|| physical_plan(&ctx, &q5_sql));
256+
b.iter(|| physical_plan(&ctx, &q6_sql));
257+
b.iter(|| physical_plan(&ctx, &q7_sql));
258+
b.iter(|| physical_plan(&ctx, &q8_sql));
259+
b.iter(|| physical_plan(&ctx, &q9_sql));
260+
b.iter(|| physical_plan(&ctx, &q10_sql));
261+
b.iter(|| physical_plan(&ctx, &q11_sql));
262+
b.iter(|| physical_plan(&ctx, &q12_sql));
263+
b.iter(|| physical_plan(&ctx, &q13_sql));
264+
b.iter(|| physical_plan(&ctx, &q14_sql));
265+
// b.iter(|| physical_plan(&ctx, &q15_sql));
266+
b.iter(|| physical_plan(&ctx, &q16_sql));
267+
b.iter(|| physical_plan(&ctx, &q17_sql));
268+
b.iter(|| physical_plan(&ctx, &q18_sql));
269+
b.iter(|| physical_plan(&ctx, &q19_sql));
270+
b.iter(|| physical_plan(&ctx, &q20_sql));
271+
b.iter(|| physical_plan(&ctx, &q21_sql));
272+
b.iter(|| physical_plan(&ctx, &q22_sql));
175273
});
176274
}
177275

0 commit comments

Comments
 (0)