@@ -8,11 +8,12 @@ use std::path::PathBuf;
88use anyhow:: Result ;
99use indicatif:: ProgressBar ;
1010use log:: warn;
11+ use vortex:: error:: VortexExpect ;
1112use vortex_datafusion:: metrics:: VortexMetricsFinder ;
1213
1314use crate :: benchmark_trait:: Benchmark ;
1415use crate :: display:: DisplayFormat ;
15- use crate :: engines:: { EngineCtx , benchmark_datafusion_query, benchmark_duckdb_query } ;
16+ use crate :: engines:: { EngineCtx , benchmark_datafusion_query} ;
1617use crate :: measurements:: { MemoryMeasurement , QueryMeasurement } ;
1718use crate :: memory:: BenchmarkMemoryTracker ;
1819use crate :: metrics:: { MetricsSetExt , export_plan_spans} ;
@@ -143,13 +144,12 @@ fn execute_queries<B: Benchmark>(
143144 tracker. start_query ( ) ;
144145 }
145146
146- match engine_ctx {
147+ let row_count = match engine_ctx {
147148 EngineCtx :: DataFusion ( ctx) => {
148149 let ( runs, ( row_count, execution_plan) ) = runtime. block_on ( async {
149150 benchmark_datafusion_query ( iterations, || async {
150- let ( batches, plan) = df:: execute_query ( & ctx. session , query_string)
151- . await
152- . unwrap_or_else ( |err| {
151+ let ( batches, plan) =
152+ ctx. execute_query ( query_string) . await . unwrap_or_else ( |err| {
153153 vortex_panic ! ( "query: {query_idx} failed with: {err}" )
154154 } ) ;
155155 let row_count: usize = batches. iter ( ) . map ( |batch| batch. num_rows ( ) ) . sum ( ) ;
@@ -158,16 +158,6 @@ fn execute_queries<B: Benchmark>(
158158 . await
159159 } ) ;
160160
161- // Validate row count if expected counts are provided
162- if let Some ( expected_counts) = expected_row_counts {
163- if query_idx < expected_counts. len ( ) {
164- assert_eq ! (
165- row_count, expected_counts[ query_idx] ,
166- "Row count mismatch for query {query_idx} - datafusion:{format}" ,
167- ) ;
168- }
169- }
170-
171161 ctx. execution_plans
172162 . push ( ( query_idx, execution_plan. clone ( ) ) ) ;
173163
@@ -193,19 +183,24 @@ fn execute_queries<B: Benchmark>(
193183 storage : url_scheme_to_storage ( benchmark. data_url ( ) ) ?,
194184 runs,
195185 } ) ;
186+
187+ row_count
196188 }
197189 EngineCtx :: DuckDB ( ctx) => {
198- let ( runs, row_count) =
199- benchmark_duckdb_query ( query_idx, query_string, iterations, ctx) ;
200-
201- // Validate row count if expected counts are provided
202- if let Some ( expected_counts) = expected_row_counts {
203- if query_idx < expected_counts. len ( ) {
204- assert_eq ! (
205- row_count, expected_counts[ query_idx] ,
206- "Row count mismatch for query {query_idx} - duckdb:{format}" ,
207- ) ;
208- }
190+ let mut runs = Vec :: with_capacity ( iterations) ;
191+ let mut row_count = None ;
192+
193+ for _ in 0 ..iterations {
194+ let ( duration, current_row_count) =
195+ ctx. execute_query ( query_string) . unwrap_or_else ( |err| {
196+ vortex_panic ! ( "query: {query_idx} failed with: {err}" )
197+ } ) ;
198+
199+ runs. push ( duration) ;
200+ row_count. inspect ( |rc| {
201+ assert_eq ! ( * rc, current_row_count, "each row count must match" )
202+ } ) ;
203+ row_count = Some ( current_row_count) ;
209204 }
210205
211206 query_measurements. push ( QueryMeasurement {
@@ -215,6 +210,18 @@ fn execute_queries<B: Benchmark>(
215210 storage : url_scheme_to_storage ( benchmark. data_url ( ) ) ?,
216211 runs,
217212 } ) ;
213+
214+ row_count. vortex_expect ( "cannot have zero runs" )
215+ }
216+ } ;
217+
218+ // Validate row count if expected counts are provided
219+ if let Some ( expected_counts) = expected_row_counts {
220+ if query_idx < expected_counts. len ( ) {
221+ assert_eq ! (
222+ row_count, expected_counts[ query_idx] ,
223+ "Row count mismatch for query {query_idx} - duckdb:{format}" ,
224+ ) ;
218225 }
219226 }
220227
0 commit comments