From 167d605edb0df9436fe8418ea75aa0f6edd2bcf7 Mon Sep 17 00:00:00 2001 From: discord9 <55937128+discord9@users.noreply.github.com> Date: Mon, 19 Oct 2026 15:37:00 +0800 Subject: [PATCH] test(promql): fold the batch-path chunk before comparing against the per-window series `a_batch_spanning_fields_and_the_flush_threshold_matches_the_per_window_path` compared the two paths as `Series`, but `push` hands out an `EvaluatedChunk`. Taking `.series` is not enough: a chunk's grid range reports the positions its push decided, which can include leading and trailing positions holding no value, while the reference assertion requires the grid range to be trimmed to the valid rows. The batch path reported `(0, 600)` against the expected `(1, 599)`. Fold the chunk back into one series first, which trims to the valid rows the same way, and compare that. The rebase also removed the `sum` helper along with the test `overlapping_window_spans_chunks`, so the now-unused `floats` helper goes with it. Signed-off-by: discord9 Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> --- src/promql/src/range_eval/tests.rs | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/promql/src/range_eval/tests.rs b/src/promql/src/range_eval/tests.rs index 122fe57a77a..26f2a51b980 100644 --- a/src/promql/src/range_eval/tests.rs +++ b/src/promql/src/range_eval/tests.rs @@ -205,17 +205,6 @@ fn all_missing(series: &Series) -> bool { }) } -/// The float values of a single-field series, in order. -fn floats(series: &Series) -> Vec { - let field = &series.fields.as_slice()[0]; - (0..field.len()) - .map(|index| match field.sample(index) { - SampleRef::Float(value) => value, - _ => panic!("expected a float"), - }) - .collect() -} - /// Pushes every chunk of one series, keeping what the evaluator hands out on the way. fn collect_chunks( evaluator: &mut RangeEvaluator, @@ -686,9 +675,14 @@ fn a_batch_spanning_fields_and_the_flush_threshold_matches_the_per_window_path() .expect("the series completes"); assert_eq!(per_window.batch_call_count(), 0); - let expected = expand(&expected); + // Fold the chunk back into one series first: a chunk's range reports the positions its push + // decided, which can include leading and trailing positions holding no value, while the + // comparison is against the trimmed series the per-window path produced. + let schema = batch.output_schema(); + let batched = fold_chunks(std::slice::from_ref(&batched), &schema); + let expected = expand(&expected.series); assert_series_eq( - Some(&batched), + batched.as_ref(), &expected, &output_metric(RangeFunction::Rate, 0), );