Add typed current-series and temporal aggregate candidates - #404
Open
zzylol wants to merge 7 commits into
Open
Conversation
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Backend issues ProjectASAP/ASAPQuery-backend#701 and ProjectASAP/ASAPQuery-backend#702 require candidate DAGs that preserve aggregate populations and expression accuracy.
What
Add typed current-series maintenance/readouts, distinct minimum state, realized temporal average, exact TopK over temporal values, and guarded relative division.
How
Planner rules produce executable typed DAGs and accuracy certificates. The backend lowers and prices these candidates without inventing the logical rewrites.
Before this PR
Current-series quantiles/TopK lacked a shared live-value contract; instant count lowered to distinct cardinality. Minimum shared the maximum family, and temporal average/quantile ratios could remain native-only.
After this PR
Quantile, TopK, sum, count, and average can share current populations with explicit grouping and maximum k. Temporal average exposes exact sum/count states for physical costing. Checked division sizes DDSketch operands against the complete ratio budget; explicitly exact temporal TopK consumes maintained values.
Evidence
Companion backend PR ProjectASAP/ASAPQuery-backend#700 passes real Prometheus 3.5.0 comparison for the issue workloads, including moving windows and guarded fallback. Performance measurements and screenshots: not applicable.
Verification
cargo +1.98.0 test --workspacepassed, 1,097 tests.Tests verify typed population sharing, row-count intent, minimum/maximum distinction, temporal-average realization, exact TopK inputs, executable DAG legality, and whole-expression relative-error composition.
Architectural decisions
The candidate declares runtime-checked division semantics. Rank-only KLL guarantees cannot establish relative value error. Exact temporal TopK adds support for explicit exact targets while preserving existing approximate heap candidate selection.
Limitations and follow-up
Requires matching backend lowering in PR 700. Runtime must enforce finite operands, a nonzero divisor, and a normal finite quotient. These tests establish correctness, not a measured speedup.
Human review — do not complete with an agent