@@ -42,6 +42,9 @@ use datafusion_common::{DEFAULT_CSV_EXTENSION, DEFAULT_PARQUET_EXTENSION};
42
42
use log:: info;
43
43
use structopt:: StructOpt ;
44
44
45
+ // hack to avoid `default_value is meaningless for bool` errors
46
+ type BoolDefaultTrue = bool ;
47
+
45
48
/// Run the tpch benchmark.
46
49
///
47
50
/// This benchmarks is derived from the [TPC-H][1] version
@@ -81,6 +84,11 @@ pub struct RunOpt {
81
84
/// Whether to disable collection of statistics (and cost based optimizations) or not.
82
85
#[ structopt( short = "S" , long = "disable-statistics" ) ]
83
86
disable_statistics : bool ,
87
+
88
+ /// If true then hash join used, if false then sort merge join
89
+ /// True by default.
90
+ #[ structopt( short = "j" , long = "prefer_hash_join" , default_value = "true" ) ]
91
+ prefer_hash_join : BoolDefaultTrue ,
84
92
}
85
93
86
94
const TPCH_QUERY_START_ID : usize = 1 ;
@@ -107,10 +115,11 @@ impl RunOpt {
107
115
}
108
116
109
117
async fn benchmark_query ( & self , query_id : usize ) -> Result < Vec < QueryResult > > {
110
- let config = self
118
+ let mut config = self
111
119
. common
112
120
. config ( )
113
121
. with_collect_statistics ( !self . disable_statistics ) ;
122
+ config. options_mut ( ) . optimizer . prefer_hash_join = self . prefer_hash_join ;
114
123
let ctx = SessionContext :: new_with_config ( config) ;
115
124
116
125
// register tables
@@ -304,7 +313,7 @@ mod tests {
304
313
use super :: * ;
305
314
306
315
use datafusion:: common:: exec_err;
307
- use datafusion:: error:: { DataFusionError , Result } ;
316
+ use datafusion:: error:: Result ;
308
317
use datafusion_proto:: bytes:: {
309
318
logical_plan_from_bytes, logical_plan_to_bytes, physical_plan_from_bytes,
310
319
physical_plan_to_bytes,
@@ -339,6 +348,7 @@ mod tests {
339
348
mem_table : false ,
340
349
output_path : None ,
341
350
disable_statistics : false ,
351
+ prefer_hash_join : true ,
342
352
} ;
343
353
opt. register_tables ( & ctx) . await ?;
344
354
let queries = get_query_sql ( query) ?;
@@ -371,6 +381,7 @@ mod tests {
371
381
mem_table : false ,
372
382
output_path : None ,
373
383
disable_statistics : false ,
384
+ prefer_hash_join : true ,
374
385
} ;
375
386
opt. register_tables ( & ctx) . await ?;
376
387
let queries = get_query_sql ( query) ?;
0 commit comments