From c75514f37cebb7dccc497bb096e809f1ecce5c92 Mon Sep 17 00:00:00 2001 From: Sam Hughes Date: Sun, 23 Mar 2025 17:36:45 -0700 Subject: [PATCH] test(cubestore): Fix decimal_partition_pruning test in release mode Makes the test wait for or induce compaction first. In release mode the test had been failing. Cherry-picked from the DF upgrade branch. --- rust/cubestore/cubestore/src/sql/mod.rs | 39 ++++++++++++++++--------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/rust/cubestore/cubestore/src/sql/mod.rs b/rust/cubestore/cubestore/src/sql/mod.rs index 2ff2144db1037..6e78957523f42 100644 --- a/rust/cubestore/cubestore/src/sql/mod.rs +++ b/rust/cubestore/cubestore/src/sql/mod.rs @@ -2812,21 +2812,34 @@ mod tests { println!("All partitions: {:#?}", partitions); - let plans = service - .plan_query("SELECT sum(num) from foo.numbers where num = 50") - .await - .unwrap(); + // Semi-busy-wait for, or, seemingly, induce, compaction for 2000 ms. + let num_attempts = 100; + for i in 0..num_attempts { + tokio::time::sleep(Duration::from_millis(20)).await; + + let plans = service + .plan_query("SELECT sum(num) from foo.numbers where num = 50") + .await + .unwrap(); + + let worker_plan = pp_phys_plan(plans.worker.as_ref()); + let parquet_regex = Regex::new(r"\d+-[a-z0-9]+\.parquet").unwrap(); + let matches = parquet_regex.captures_iter(&worker_plan).count(); + let chunk_parquet_regex = Regex::new(r"\d+-[a-z0-9]+\.chunk\.parquet").unwrap(); + let chunk_matches = chunk_parquet_regex.captures_iter(&worker_plan).count(); - let worker_plan = pp_phys_plan(plans.worker.as_ref()); - println!("Worker Plan: {}", worker_plan); - let parquet_regex = Regex::new(r"\d+-[a-z0-9]+.parquet").unwrap(); - let matches = parquet_regex.captures_iter(&worker_plan).count(); - assert!( // TODO 2 because partition pruning doesn't respect half open intervals yet - matches < 3 && matches > 0, - "{}\nshould have 2 and less partition scan nodes", - worker_plan - ); + if matches < 3 && matches > 0 && chunk_matches == 0 { + break; + } else if i == num_attempts - 1 { + panic!( + "{}\nshould have 2 and less partition scan nodes, matches = {}, chunk_matches = {}", + worker_plan, + matches, + chunk_matches, + ); + } + } }) .await; }