Skip to content

fix(planner): restrict DeltaSetAggregator to tumbling windows - #606

Merged
milindsrivastava1997 merged 4 commits into
mainfrom
worktree-issue-588
Aug 25, 2026
Merged

fix(planner): restrict DeltaSetAggregator to tumbling windows#606
milindsrivastava1997 merged 4 commits into
mainfrom
worktree-issue-588

Conversation

@milindsrivastava1997

@milindsrivastava1997 milindsrivastava1997 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • DeltaSetAggregator only tracks added/removed keys since the last window, so it's only correct for non-overlapping (tumbling) windows. Nothing enforced this, so a Sliding DeltaSetAggregator config could be planned/selected and silently produce wrong merged add/remove sets.
  • agg_config.rs: force the DeltaSetAggregator companion config to Tumbling regardless of the surrounding query's window_type, sized to the sibling's slide_interval_ms.
  • candidate_gen.rs: the (not-yet-wired-in) cost optimizer no longer enumerates Sliding candidates for DeltaSetAggregator.
  • capability_matching.rs: new key_agg_window_valid() gate, wired into window_compatible() and the key-agg pairing lookup (which previously bypassed window checking entirely) — the actual belt-and-suspenders fix that stops a bad config from ever being selected to serve a query.

Closes #588.

Test plan

  • TDD: red tests written per fix site, confirmed failing, then made to pass
  • cargo test -p asap_planner -p query_engine_rust -p asap_types --lib — 695 tests pass, 0 failures

🤖 Generated with Claude Code

milindsrivastava1997 and others added 3 commits August 25, 2026 12:28
…y window_type (#588)

DeltaSetAggregator only tracks added/removed keys since the last
window, so it's only correct for non-overlapping (tumbling) windows.
build_agg_configs_for_statistics was copying the surrounding query's
window_type straight through, which would silently plan a Sliding
DeltaSetAggregator once sliding windows are enabled.

Always plan the companion config as Tumbling, sized to the sibling
value aggregation's slide_interval_ms so its buckets align with the
pane-close cadence the value aggregation already emits at. No-op
under Tumbling (the only window_type the live planner produces today).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
…ration (#588)

candidate_gen.rs's enumerate_candidates was enumerating Sliding window
candidates for every agg type compatible with Statistic::Cardinality,
including DeltaSetAggregator -- which is only correct under
non-overlapping (tumbling) windows. This optimizer module isn't wired
into the live planner yet, but should already encode the invariant
before it is.

Skip Sliding entries from window_candidates() when agg_type is
DeltaSetAggregator; Tumbling candidates for it, and Sliding candidates
for its siblings (SetAggregator, HLL), are unaffected.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
…hing (#588)

DeltaSetAggregator only tracks added/removed keys since the last
window, so it's only correct for non-overlapping (tumbling) windows.
The two planner-side producers were fixed to never emit one, but
find_compatible_aggregation's paired-key-agg lookup matched candidates
by (metric, is_key_agg_type) alone, bypassing window_compatible
entirely -- a Sliding DeltaSetAggregator built by any other path could
still be selected to serve a query and silently produce incorrect
merged add/remove sets.

Add key_agg_window_valid() as the single source of truth for this
invariant, wired into both window_compatible() (the value-slot
matching path) and the key-agg find() filter (the actual pairing path
CountMinSketch/HydraKLL rely on). When a key agg exists on the metric
but gets filtered out for this reason, log the specific cause instead
of the generic "none found" warning.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@milindsrivastava1997
milindsrivastava1997 marked this pull request as ready for review August 25, 2026 16:42
@milindsrivastava1997

Copy link
Copy Markdown
Contributor Author

Reviewed — build/tests pass, no correctness regressions found in the DeltaSetAggregator/Sliding fix (#588).

Two minor cleanups:

  • candidate_gen.rs:57 duplicates the DeltaSetAggregator+Sliding rejection inline instead of calling the new key_agg_window_valid predicate — could drift if the invariant is extended later.
  • capability_matching.rs:285 scans configs.values() twice on the miss path just to build a more detailed warn log.

@milindsrivastava1997 milindsrivastava1997 changed the title fix(planner): restrict DeltaSetAggregator to tumbling windows (#588) fix(planner): restrict DeltaSetAggregator to tumbling windows Aug 25, 2026
- candidate_gen.rs: call the shared key_agg_window_valid predicate
  instead of duplicating the DeltaSetAggregator+Sliding check inline,
  so the invariant has one source of truth.
- capability_matching.rs: fold the key-agg miss-path diagnostic into
  the same single pass over configs.values() instead of re-scanning
  to find the rejected candidate separately.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@milindsrivastava1997
milindsrivastava1997 merged commit ef34f63 into main Aug 25, 2026
6 checks passed
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.

DeltaSetAggregator must be restricted to tumbling windows

1 participant