Skip to content
Merged
Show file tree
Hide file tree
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
20 changes: 14 additions & 6 deletions datafusion/benches/filter_query_sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,14 @@ use datafusion::prelude::ExecutionContext;
use datafusion::{datasource::MemTable, error::Result};
use futures::executor::block_on;
use std::sync::Arc;
use tokio::runtime::Runtime;

async fn query(ctx: &mut ExecutionContext, sql: &str) {
let rt = Runtime::new().unwrap();

// execute the query
let df = ctx.sql(sql).unwrap();
let results = df.collect().await.unwrap();

// display the relation
for _batch in results {
// println!("num_rows: {}", _batch.num_rows());
}
criterion::black_box(rt.block_on(df.collect()).unwrap());
}

fn create_context(array_len: usize, batch_size: usize) -> Result<ExecutionContext> {
Expand Down Expand Up @@ -85,6 +83,16 @@ fn criterion_benchmark(c: &mut Criterion) {
))
})
});

c.bench_function("filter_scalar in list", |b| {
let mut ctx = create_context(array_len, batch_size).unwrap();
b.iter(|| {
block_on(query(
&mut ctx,
"select f32, f64 from t where f32 in (10, 20, 30, 40)",
))
})
});
}

criterion_group!(benches, criterion_benchmark);
Expand Down
Loading