Skip to content

Commit 11554a4

Browse files
authored
Idempotent DuckDB bench (#3362)
1 parent 3f76def commit 11554a4

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

bench-vortex/src/bin/clickbench.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use indicatif::ProgressBar;
2020
use itertools::Itertools;
2121
use log::warn;
2222
use prelude::SessionContext;
23-
use tempfile::{TempDir, tempdir};
2423
use tokio::runtime::Runtime;
2524
use tracing::{debug, info_span};
2625
use tracing_futures::Instrument;
@@ -89,15 +88,13 @@ struct DataFusionCtx {
8988

9089
struct DuckDBCtx {
9190
duckdb_path: PathBuf,
92-
tmp_dir: TempDir,
9391
}
9492

9593
impl DuckDBCtx {
9694
pub fn duckdb_file(&self, format: Format) -> PathBuf {
97-
self.tmp_dir
98-
.path()
99-
.to_path_buf()
100-
.join(format!("hits-{format}.db"))
95+
let dir = Path::new("bench-vortex/data/duckdb");
96+
std::fs::create_dir_all(dir).vortex_expect("failed to create duckdb data dir");
97+
dir.join(format!("{format}.db"))
10198
}
10299
}
103100

@@ -119,7 +116,6 @@ impl EngineCtx {
119116
fn new_with_duckdb(duckdb_path: &Path) -> Self {
120117
EngineCtx::DuckDB(DuckDBCtx {
121118
duckdb_path: duckdb_path.to_path_buf(),
122-
tmp_dir: tempdir().vortex_expect("cannot open temp directory"),
123119
})
124120
}
125121

bench-vortex/src/engines/ddb/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ fn create_table_registration(
153153
for table_name in &tables {
154154
let table_path = format!("{base_dir}{table_name}.{extension}");
155155
commands.push_str(&format!(
156-
"CREATE {} {table_name} AS SELECT * FROM read_{extension}('{table_path}');\n",
156+
"CREATE {} IF NOT EXISTS {table_name} AS SELECT * FROM read_{extension}('{table_path}');\n",
157157
duckdb_object.to_str(),
158158
));
159159
}
@@ -167,7 +167,7 @@ fn create_table_registration(
167167
};
168168

169169
format!(
170-
"CREATE {} hits AS SELECT * FROM read_{extension}('{file_glob}');",
170+
"CREATE {} IF NOT EXISTS hits AS SELECT * FROM read_{extension}('{file_glob}');",
171171
duckdb_object.to_str()
172172
)
173173
}
@@ -178,7 +178,7 @@ fn create_table_registration(
178178
for table_name in tables {
179179
let table_path = format!("{base_dir}{table_name}.{extension}");
180180
commands.push_str(&format!(
181-
"CREATE {} {table_name} AS SELECT * FROM read_{extension}('{table_path}');\n",
181+
"CREATE {} IF NOT EXISTS {table_name} AS SELECT * FROM read_{extension}('{table_path}');\n",
182182
duckdb_object.to_str(),
183183
));
184184
}

0 commit comments

Comments
 (0)