|
20 | 20 | use arrow::array::{ArrayRef, Int32Array, StringArray, StructArray}; |
21 | 21 | use arrow::datatypes::{DataType, Field, Fields, Schema, SchemaRef}; |
22 | 22 | use arrow::record_batch::RecordBatch; |
23 | | -use criterion::{criterion_group, criterion_main, Criterion}; |
| 23 | +use criterion::{Criterion, criterion_group, criterion_main}; |
24 | 24 | use datafusion::prelude::SessionContext; |
25 | 25 | use datafusion_common::instant::Instant; |
26 | 26 | use parquet::arrow::ArrowWriter; |
@@ -98,11 +98,7 @@ fn generate_batch(batch_id: usize) -> RecordBatch { |
98 | 98 | ), |
99 | 99 | ]); |
100 | 100 |
|
101 | | - RecordBatch::try_new( |
102 | | - schema, |
103 | | - vec![id_array, Arc::new(struct_array)], |
104 | | - ) |
105 | | - .unwrap() |
| 101 | + RecordBatch::try_new(schema, vec![id_array, Arc::new(struct_array)]).unwrap() |
106 | 102 | } |
107 | 103 |
|
108 | 104 | fn generate_file() -> NamedTempFile { |
@@ -210,11 +206,13 @@ fn criterion_benchmark(c: &mut Criterion) { |
210 | 206 | }); |
211 | 207 |
|
212 | 208 | c.bench_function("filter_struct_range", |b| { |
213 | | - b.iter(|| query( |
214 | | - &ctx, |
215 | | - &rt, |
216 | | - "select id from t where s['id'] > 100 and s['id'] < 200" |
217 | | - )) |
| 209 | + b.iter(|| { |
| 210 | + query( |
| 211 | + &ctx, |
| 212 | + &rt, |
| 213 | + "select id from t where s['id'] > 100 and s['id'] < 200", |
| 214 | + ) |
| 215 | + }) |
218 | 216 | }); |
219 | 217 |
|
220 | 218 | // Join queries (limited with WHERE id < 1000 for performance) |
@@ -272,28 +270,34 @@ fn criterion_benchmark(c: &mut Criterion) { |
272 | 270 | }); |
273 | 271 |
|
274 | 272 | c.bench_function("group_by_struct_with_count", |b| { |
275 | | - b.iter(|| query( |
276 | | - &ctx, |
277 | | - &rt, |
278 | | - "select s['id'], count(*) from t group by s['id']" |
279 | | - )) |
| 273 | + b.iter(|| { |
| 274 | + query( |
| 275 | + &ctx, |
| 276 | + &rt, |
| 277 | + "select s['id'], count(*) from t group by s['id']", |
| 278 | + ) |
| 279 | + }) |
280 | 280 | }); |
281 | 281 |
|
282 | 282 | c.bench_function("group_by_multiple_with_count", |b| { |
283 | | - b.iter(|| query( |
284 | | - &ctx, |
285 | | - &rt, |
286 | | - "select id, s['id'], count(*) from t group by id, s['id']" |
287 | | - )) |
| 283 | + b.iter(|| { |
| 284 | + query( |
| 285 | + &ctx, |
| 286 | + &rt, |
| 287 | + "select id, s['id'], count(*) from t group by id, s['id']", |
| 288 | + ) |
| 289 | + }) |
288 | 290 | }); |
289 | 291 |
|
290 | 292 | // Additional queries |
291 | 293 | c.bench_function("order_by_struct_limit", |b| { |
292 | | - b.iter(|| query( |
293 | | - &ctx, |
294 | | - &rt, |
295 | | - "select id, s['id'] from t order by s['id'] limit 1000" |
296 | | - )) |
| 294 | + b.iter(|| { |
| 295 | + query( |
| 296 | + &ctx, |
| 297 | + &rt, |
| 298 | + "select id, s['id'] from t order by s['id'] limit 1000", |
| 299 | + ) |
| 300 | + }) |
297 | 301 | }); |
298 | 302 |
|
299 | 303 | c.bench_function("distinct_struct_field", |b| { |
|
0 commit comments