Skip to content

Commit

Permalink
fmt and clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
wangpatrick57 committed Apr 30, 2024
1 parent 37197af commit b7dd7e6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
25 changes: 14 additions & 11 deletions optd-perftest/src/datafusion_dbms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl CardtestRunnerDBMSHelper for DatafusionDBMS {
) -> anyhow::Result<Vec<usize>> {
let base_table_stats = self.get_benchmark_stats(benchmark).await?;
// clear_state() is how we "load" the stats into datafusion
self.clear_state(Some(base_table_stats), &benchmark).await?;
self.clear_state(Some(base_table_stats), benchmark).await?;

if self.adaptive {
// We need to load the stats if we're doing adaptivity because that involves executing the queries in datafusion.
Expand Down Expand Up @@ -95,7 +95,11 @@ impl DatafusionDBMS {
///
/// A more ideal way to generate statistics would be to use the `ANALYZE`
/// command in SQL, but DataFusion does not support that yet.
async fn clear_state(&mut self, stats: Option<DataFusionBaseTableStats>, benchmark: &Benchmark) -> anyhow::Result<()> {
async fn clear_state(
&mut self,
stats: Option<DataFusionBaseTableStats>,
benchmark: &Benchmark,
) -> anyhow::Result<()> {
let with_logical = match benchmark {
Benchmark::Tpch(_) => WITH_LOGICAL_FOR_TPCH,
Benchmark::Job(_) | Benchmark::Joblight(_) => WITH_LOGICAL_FOR_JOB,
Expand Down Expand Up @@ -263,7 +267,7 @@ impl DatafusionDBMS {
/// This is used to execute the query in order to load the true cardinalities back into optd
/// in order to use the adaptive cost model.
async fn execute_query(&self, sql: &str) -> anyhow::Result<()> {
Self::execute(&self.get_ctx(), sql).await?;
Self::execute(self.get_ctx(), sql).await?;
Ok(())
}

Expand Down Expand Up @@ -319,7 +323,7 @@ impl DatafusionDBMS {
}
Benchmark::Job(_) | Benchmark::Joblight(_) => {
let job_kit = JobKit::build(&self.workspace_dpath)?;
Self::create_job_tables(&self.get_ctx(), &job_kit).await?;
Self::create_job_tables(self.get_ctx(), &job_kit).await?;
}
};
Ok(())
Expand All @@ -333,7 +337,7 @@ impl DatafusionDBMS {
.filter(|s| !s.is_empty())
.collect::<Vec<_>>();
for ddl in ddls {
Self::execute(&self.get_ctx(), ddl).await?;
Self::execute(self.get_ctx(), ddl).await?;
}
Ok(())
}
Expand Down Expand Up @@ -367,7 +371,7 @@ impl DatafusionDBMS {
for tbl_fpath in tbl_fpath_iter {
let tbl_name = tbl_fpath.file_stem().unwrap().to_str().unwrap();
Self::execute(
&self.get_ctx(),
self.get_ctx(),
&format!(
"create external table {}_tbl stored as csv delimiter '|' location '{}';",
tbl_name,
Expand All @@ -392,7 +396,7 @@ impl DatafusionDBMS {
.collect::<Vec<_>>()
.join(", ");
Self::execute(
&self.get_ctx(),
self.get_ctx(),
&format!(
"insert into {} select {} from {}_tbl;",
tbl_name, projection_list, tbl_name,
Expand All @@ -413,7 +417,7 @@ impl DatafusionDBMS {

// Download the tables.
let job_kit = JobKit::build(&self.workspace_dpath)?;
job_kit.download_tables(&job_kit_config)?;
job_kit.download_tables(job_kit_config)?;

// Create the tables.
Self::create_job_tables(&ctx, &job_kit).await?;
Expand All @@ -422,8 +426,7 @@ impl DatafusionDBMS {
let tbl_fpath_iter = job_kit.get_tbl_fpath_iter().unwrap();
for tbl_fpath in tbl_fpath_iter {
let tbl_name = tbl_fpath.file_stem().unwrap().to_str().unwrap();
let schema =
ctx
let schema = ctx
.catalog("datafusion")
.unwrap()
.schema("public")
Expand All @@ -434,7 +437,7 @@ impl DatafusionDBMS {
.schema();
self.get_ctx()
.register_csv(
&tbl_name,
tbl_name,
tbl_fpath.to_str().unwrap(),
CsvReadOptions::new()
.schema(&schema)
Expand Down
3 changes: 2 additions & 1 deletion optd-perftest/src/tpch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ use std::path::{Path, PathBuf};
const TPCH_KIT_REPO_URL: &str = "https://github.com/wangpatrick57/tpch-kit.git";
pub const TPCH_KIT_POSTGRES: &str = "POSTGRESQL";
const NUM_TPCH_QUERIES: usize = 22;
pub const WORKING_QUERY_IDS: &[&str] = &["2", "3", "5", "7", "8", "9", "10", "12", "13", "14", "17"];
pub const WORKING_QUERY_IDS: &[&str] =
&["2", "3", "5", "7", "8", "9", "10", "12", "13", "14", "17"];

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct TpchKitConfig {
Expand Down

0 comments on commit b7dd7e6

Please sign in to comment.