Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions benchmarks/src/clickbench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,6 @@ impl RunOpt {
}

let rt = self.common.build_runtime()?;
let ctx = SessionContext::new_with_config_rt(config, rt);

self.register_hits(&ctx).await?;

let mut benchmark_run = BenchmarkRun::new();
for query_id in query_range {
Expand All @@ -224,6 +221,12 @@ impl RunOpt {
}
break;
};

// Create a fresh session context for each query so the table
// is re-registered (and metadata re-fetched) every time.
let ctx = SessionContext::new_with_config_rt(config.clone(), rt.clone());
self.register_hits_via_ddl(&ctx).await?;

benchmark_run.start_new_case(&format!("Query {query_id}"));
let query_run = self.benchmark_query(&sql, query_id, &ctx).await;
match query_run {
Expand Down Expand Up @@ -348,6 +351,21 @@ impl RunOpt {
Ok(())
}

/// Registers hits_raw via CREATE EXTERNAL TABLE DDL and creates the hits view.
/// This is used to re-register the table for each query to observe metadata fetching.
async fn register_hits_via_ddl(&self, ctx: &SessionContext) -> Result<()> {
let path = self.path.as_os_str().to_str().unwrap();
let create_table_sql = format!(
"CREATE EXTERNAL TABLE hits_raw \
STORED AS PARQUET \
LOCATION '{path}' \
OPTIONS ('binary_as_string' 'true')"
);
ctx.sql(&create_table_sql).await?.collect().await?;
ctx.sql(HITS_VIEW_DDL).await?.collect().await?;
Ok(())
}

fn iterations(&self) -> usize {
self.common.iterations
}
Expand Down
Loading