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 <discord9@users.noreply.github.com>
Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>
This commit is contained in:
discord9
2026-10-19 15:37:00 +08:00
parent efc8d07aa9
commit 167d605edb
+7 -13
View File
@@ -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<f64> {
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),
);