Skip to content

Commit 604980a

Browse files
working
1 parent 14c9b7f commit 604980a

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

src/bin/fuzz.rs

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ struct Cli {
2121

2222
/// Trait for defining workloads that can be fuzzed
2323
#[async_trait]
24-
trait Workload: Send + Sync {
24+
trait Workload {
2525
/// Setup the workload by registering tables and preparing data
26-
async fn setup(&self, ctx: &SessionContext) -> Result<()>;
26+
async fn setup(ctx: SessionContext) -> Result<()>;
2727

2828
/// Get queries as an iterator of (query_name, query_sql) pairs
2929
async fn queries(&self) -> Result<Vec<(String, String)>>;
@@ -70,10 +70,9 @@ impl TpcdsWorkload {
7070

7171
#[async_trait]
7272
impl Workload for TpcdsWorkload {
73-
async fn setup(&self, ctx: &SessionContext) -> Result<()> {
74-
// Register tables
75-
info!("🔧 Registering TPC-DS tables...");
76-
let (registered_tables, missing_tables) = register_available_tpcds_tables(ctx, None).await?;
73+
async fn setup(ctx: SessionContext) -> Result<()> {
74+
info!("Registering TPC-DS tables...");
75+
let (registered_tables, missing_tables) = register_available_tpcds_tables(&ctx, None).await?;
7776

7877
if !missing_tables.is_empty() {
7978
debug!("Missing TPCDS tables: {:?}", missing_tables);
@@ -144,21 +143,14 @@ fn validate_tpcds_args(scale_factor: &str) -> std::result::Result<(), String> {
144143
}
145144

146145
/// Run a workload using the generic workload trait
147-
async fn run_workload(workload: TpcdsWorkload) -> Result<()> {
146+
async fn run_workload<W>(workload: W) -> Result<()>
147+
where W: Workload {
148148
info!("📊 Running {} workload...", workload.name());
149149

150150
// Create FuzzDB with randomized session config
151151
info!("⚙️ Setting up distributed session with randomized configuration...");
152152

153-
let fuzz_db = match FuzzDB::new({
154-
let workload_clone = workload.clone();
155-
move |ctx| {
156-
let workload_inner = workload_clone.clone();
157-
async move {
158-
workload_inner.setup(&ctx).await
159-
}
160-
}
161-
}).await {
153+
let fuzz_db = match FuzzDB::new(W::setup).await {
162154
Ok(db) => db,
163155
Err(e) => {
164156
return Err(datafusion::error::DataFusionError::Execution(format!(
@@ -183,7 +175,7 @@ async fn run_workload(workload: TpcdsWorkload) -> Result<()> {
183175
let start_time = Instant::now();
184176

185177
for (query_name, query_sql) in all_queries {
186-
debug!("🔄 Executing query: {}", query_name);
178+
info!("Executing query: {}", query_name);
187179
debug!("Executing fuzz query: {}", query_sql.trim());
188180

189181
let query_start = Instant::now();

0 commit comments

Comments
 (0)