Skip to content

refactor(query-engine): remove is_exact_query as a threaded bool - #628

Merged
milindsrivastava1997 merged 1 commit into
mainfrom
worktree-issue-613
Aug 26, 2026
Merged

refactor(query-engine): remove is_exact_query as a threaded bool#628
milindsrivastava1997 merged 1 commit into
mainfrom
worktree-issue-613

Conversation

@milindsrivastava1997

Copy link
Copy Markdown
Contributor

What

StoreQueryParams::is_exact_query was a bool computed once and threaded through StoreQueryPlan, then consulted by execute_store_query to pick between store fetch strategies. Every StoreQueryParams builder had to independently derive it correctly, and past call sites already drifted out of sync more than once (#580, #582, #608).

Since #616 replaced the tolerant-scan branch with scan_windows_via_exact (a grid-walk of exact lookups), the flag's only remaining job was choosing between that grid-walk and a single direct exact call — but a range exactly one window wide already makes scan_windows_via_exact degenerate to a single exact lookup. So the flag goes away entirely:

  • create_store_query_plan still narrows the Sliding-instant values query to one window's width (unchanged math), but now returns WindowType alongside the plan instead of stashing a derived bool on the struct.
  • create_keys_query_params and finish_range_context no longer set anything — the "always grid-walk" behavior for keys/range falls out naturally from execute_store_query always calling scan_windows_via_exact, with nothing left to drift out of sync.
  • execute_store_query collapsed to a thin wrapper that always calls scan_windows_via_exact.
  • execute_and_merge_store_queries's Sliding-vs-Tumbling merge decision (unrelated to fetch mechanism) now takes WindowType as an explicit parameter instead of re-deriving it from the removed field.
  • QueryExecutionContext gained a value_window_type field, threaded through all three query-language front-ends (PromQL, Elastic, SQL).

Testing

Added window_semantics_consistency_tests.rs: hardening tests written against the observable PromQL query surface (not internal struct/function names) so they hold regardless of internal reshaping — covering Sliding/Tumbling instant-vs-range agreement (including the historical overlap-summing bug shape), keys queries over each WindowType, and window-grid boundary cases (exact-width vs narrower-than-bucket spans).

cargo check --tests, cargo clippy -- -D warnings, and cargo fmt --check all clean. Full suite: 505/505 passing, zero regressions.

Fixes #613.

🤖 Generated with Claude Code

StoreQueryParams::is_exact_query was a bool computed once and threaded
through StoreQueryPlan, then consulted by execute_store_query to pick
between store fetch strategies. Every StoreQueryParams builder had to
independently derive it correctly, and past call sites already drifted
out of sync more than once (#580, #582, #608).

Since #616 replaced the tolerant-scan branch with scan_windows_via_exact
(a grid-walk of exact lookups), the flag's only remaining job was
choosing between that grid-walk and a single direct exact call -- but a
range exactly one window wide already makes scan_windows_via_exact
degenerate to a single exact lookup. So it can go away entirely:
create_store_query_plan still narrows the Sliding-instant values query to
one window's width (unchanged), and execute_store_query now
unconditionally calls scan_windows_via_exact.

The one other thing is_exact_query did -- telling
execute_and_merge_store_queries whether to use Sliding or Tumbling merge
semantics -- is unrelated to fetch mechanism and is now passed explicitly
as a WindowType parameter, sourced from create_store_query_plan's (now
three-element) return value and threaded onto QueryExecutionContext.

Also adds window_semantics_consistency_tests.rs: hardening tests written
against the observable PromQL query surface (not internal struct/function
names), covering Sliding/Tumbling instant-vs-range agreement, keys
queries over each WindowType, and window-grid boundary cases.

Fixes #613.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@milindsrivastava1997
milindsrivastava1997 marked this pull request as ready for review August 26, 2026 03:47
@milindsrivastava1997
milindsrivastava1997 merged commit 09ff227 into main Aug 26, 2026
16 checks passed
@milindsrivastava1997
milindsrivastava1997 deleted the worktree-issue-613 branch August 26, 2026 04:06
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.

Remove is_exact_query as a threaded bool; infer scan-vs-exact from WindowType at each call site

1 participant