Skip to content

fix(query-engine): merge all sliding-window buckets per key instead of taking first - #570

Merged
milindsrivastava1997 merged 3 commits into
mainfrom
567-1-sliding-bucket-merge-fix
Aug 23, 2026
Merged

fix(query-engine): merge all sliding-window buckets per key instead of taking first#570
milindsrivastava1997 merged 3 commits into
mainfrom
567-1-sliding-bucket-merge-fix

Conversation

@milindsrivastava1997

Copy link
Copy Markdown
Contributor

Summary

  • execute_and_merge_store_queries's Sliding-window branch kept only the first precomputed bucket per key and discarded the rest when the store returned more than expected — DataFusion's SummaryMergeMultipleExec already merges all of them correctly, so this was a real native/DataFusion behavior gap.
  • Fixes it to merge everything, warning (not dropping) when the bucket count differs from the expected 1.

Stage 1 of #567 (converting binary-arithmetic PromQL instant queries from DataFusion to native execution) — this closes the gap before binary-expr queries move onto this native path in a later stage, so the cutover doesn't inherit the bug.

Test plan

  • New native_pipeline_merge_tests.rs: single-bucket baseline, multi-bucket merge (red before the fix, green after), 3-bucket generalization, Tumbling-branch regression guard
  • Full cargo test --lib (536 tests) green
  • cargo clippy --lib --tests -- -D warnings clean

Side finding filed separately as #569 (pre-existing, unrelated Tumbling-path panic surfaced while writing the regression guard).

milindsrivastava1997 and others added 3 commits August 22, 2026 22:46
…f taking first

execute_and_merge_store_queries kept only the first precomputed bucket
per key for Sliding-window queries, discarding the rest when the store
returned more than expected. DataFusion's SummaryMergeMultipleExec
already merges all of them correctly, so binary-expr queries (still on
DataFusion) don't hit this. #567 will move binary-expr onto this native
path, so this native/DataFusion behavior gap needed closing first.

Part of #567 Stage 1.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
… and stale latency label

- Sliding branch now delegates to merge_precomputed_outputs (do_merge=true)
  instead of hand-rolling its own extract/merge/insert loop, removing the
  duplication with the Tumbling branch's merge path.
- merge_accumulators now takes ownership of the accumulator Vec so its
  single-element shortcut can move the value out instead of re-cloning it
  on top of the clone already done to build the Vec.
- The [LATENCY] log's merge/no-merge label was hardcoded off window_type
  and said "no merge" even when merge_accumulators was in fact called;
  it now reflects whether merging actually occurs.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…compute buckets

merge_precomputed_outputs silently skipped any key whose timestamped_buckets
list was empty, with no log signal — unlike the "found N, expected 1"
mismatch case a few lines up in the Sliding caller, which does warn. Since
this function is shared by Sliding, Tumbling, and the keys-merge path, the
warn now covers all three instead of being Sliding-only.

Also files #575 to compute EXPECTED_BUCKETS_PER_KEY instead of hardcoding it
to 1, since #554 will make >1 legitimate whenever a sliding-window query's
range exceeds the window size.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@milindsrivastava1997
milindsrivastava1997 force-pushed the 567-1-sliding-bucket-merge-fix branch from 506489e to 8e768fa Compare August 23, 2026 02:46
@milindsrivastava1997
milindsrivastava1997 merged commit 7c2eb98 into main Aug 23, 2026
5 checks passed
@milindsrivastava1997
milindsrivastava1997 deleted the 567-1-sliding-bucket-merge-fix branch August 23, 2026 02:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant