Skip to content

Add typed current-series and temporal aggregate candidates - #404

Open
zzylol wants to merge 7 commits into
mainfrom
feat/current-series-rules
Open

Add typed current-series and temporal aggregate candidates#404
zzylol wants to merge 7 commits into
mainfrom
feat/current-series-rules

Conversation

@zzylol

@zzylol zzylol commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

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

  • Unit/integration/doc tests: cargo +1.98.0 test --workspace passed, 1,097 tests.
  • End-to-end tests: companion backend compatibility suite passed 14 tests, with one existing Collector-schema test ignored.
  • Other checks: workspace/all-targets clippy passed with warnings denied; formatting passed.

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

  • The MVP boundary is correct.
  • New conceptual layers or public interfaces are necessary.
  • The before/after description matches the intended product behavior.
  • Human reviewer:
  • Decision and rationale:

@zzylol zzylol changed the title Add rules and typed IR for shared current-series quantiles and TopK Add typed current-series and temporal aggregate candidates Sep 12, 2026
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