@@ -397,14 +397,25 @@ fn canonical_tpc_scale_factor(scale_factor: &str) -> String {
397397}
398398
399399fn v3_query_idx ( qm : & QueryMeasurement ) -> u32 {
400- let query_idx = if matches ! ( & qm. benchmark_dataset, BenchmarkDataset :: ClickBench { .. } ) {
400+ let query_idx = if query_source_is_zero_based ( & qm. benchmark_dataset ) {
401401 qm. query_idx . saturating_add ( 1 )
402402 } else {
403403 qm. query_idx
404404 } ;
405405 u32:: try_from ( query_idx) . unwrap_or ( u32:: MAX )
406406}
407407
408+ fn query_source_is_zero_based ( dataset : & BenchmarkDataset ) -> bool {
409+ matches ! (
410+ dataset,
411+ BenchmarkDataset :: ClickBench { .. }
412+ | BenchmarkDataset :: StatPopGen { .. }
413+ | BenchmarkDataset :: PolarSignals { .. }
414+ | BenchmarkDataset :: Fineweb
415+ | BenchmarkDataset :: GhArchive
416+ )
417+ }
418+
408419fn engine_label ( engine : Engine ) -> & ' static str {
409420 match engine {
410421 Engine :: Vortex => "vortex" ,
@@ -516,6 +527,64 @@ mod tests {
516527 ) ;
517528 }
518529
530+ #[ test]
531+ fn zero_based_query_sources_emit_one_based_query_idx ( ) {
532+ let datasets = [
533+ BenchmarkDataset :: ClickBench {
534+ flavor : Flavor :: Partitioned ,
535+ } ,
536+ BenchmarkDataset :: StatPopGen { n_rows : 100_000 } ,
537+ BenchmarkDataset :: PolarSignals { n_rows : 1_000_000 } ,
538+ BenchmarkDataset :: Fineweb ,
539+ BenchmarkDataset :: GhArchive ,
540+ ] ;
541+
542+ for benchmark_dataset in datasets {
543+ let qm = QueryMeasurement {
544+ query_idx : 0 ,
545+ target : Target :: new ( Engine :: DataFusion , Format :: Parquet ) ,
546+ benchmark_dataset,
547+ benchmark_runner : "ci-runner" . to_string ( ) ,
548+ storage : "nvme" . to_string ( ) ,
549+ runs : vec ! [ Duration :: from_nanos( 1 ) ] ,
550+ } ;
551+ let V3Record :: QueryMeasurement ( record) = query_measurement_record ( & qm, None ) else {
552+ panic ! ( "expected query measurement record" ) ;
553+ } ;
554+ assert_eq ! ( record. query_idx, 1 ) ;
555+ }
556+ }
557+
558+ #[ test]
559+ fn one_based_query_sources_keep_query_idx ( ) {
560+ let datasets = [
561+ BenchmarkDataset :: TpcH {
562+ scale_factor : "1" . to_string ( ) ,
563+ } ,
564+ BenchmarkDataset :: TpcDS {
565+ scale_factor : "1" . to_string ( ) ,
566+ } ,
567+ BenchmarkDataset :: PublicBi {
568+ name : "cms-provider" . to_string ( ) ,
569+ } ,
570+ ] ;
571+
572+ for benchmark_dataset in datasets {
573+ let qm = QueryMeasurement {
574+ query_idx : 1 ,
575+ target : Target :: new ( Engine :: DataFusion , Format :: Parquet ) ,
576+ benchmark_dataset,
577+ benchmark_runner : "ci-runner" . to_string ( ) ,
578+ storage : "nvme" . to_string ( ) ,
579+ runs : vec ! [ Duration :: from_nanos( 1 ) ] ,
580+ } ;
581+ let V3Record :: QueryMeasurement ( record) = query_measurement_record ( & qm, None ) else {
582+ panic ! ( "expected query measurement record" ) ;
583+ } ;
584+ assert_eq ! ( record. query_idx, 1 ) ;
585+ }
586+ }
587+
519588 #[ test]
520589 fn snapshot_compression_time_encode ( ) -> anyhow:: Result < ( ) > {
521590 let timing = CompressionTimingMeasurement {
0 commit comments