feat(planner): classify ASAPQuery rules into existing strategies - #333
Merged
Merged
Conversation
zzylol
force-pushed
the
feat/asapquery-rule-coverage
branch
from
September 2, 2026 21:45
1acc47b to
d1b6dc6
Compare
zzylol
force-pushed
the
feat/asapquery-rule-coverage
branch
from
September 2, 2026 21:46
d1b6dc6 to
2d3428c
Compare
zzylol
marked this pull request as ready for review
September 3, 2026 00:57
milindsrivastava1997
approved these changes
Sep 3, 2026
zzylol
force-pushed
the
feat/asapquery-rule-coverage
branch
from
September 3, 2026 01:30
2d3428c to
e21cce1
Compare
zzylol
changed the base branch from
feat/dag-viewer-cost-annotations-286
to
main
September 3, 2026 01:31
zzylol
force-pushed
the
feat/asapquery-rule-coverage
branch
2 times, most recently
from
September 3, 2026 01:45
588a4f7 to
3f5074c
Compare
zzylol
force-pushed
the
feat/asapquery-rule-coverage
branch
from
September 3, 2026 02:03
3f5074c to
22f8757
Compare
Contributor
Author
|
TODO: sum ∘ count this rule may have counter example later. |
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
ASAPQuery contains useful planner and optimizer rules, but copying PromQL syntax patterns into a parallel ASAPPlanner strategy would duplicate ownership and make coverage language-specific. The rules need to be audited by semantic decision and assigned to the ASAPPlanner component that already owns that decision.
What
2586400b3b0436a5414c901ebce07065d20b5223.sum ∘ sum,sum ∘ count,min ∘ min, andmax ∘ max.SemanticEquivalentRewriteStrategy;AvgToSumOverCountStrategyremains a compatibility export.PatternStrategyand no standalone aggregate-composition strategy or module.How
Temporal and spatial function recognition remains front-end lowering into typed
AggIntent. Algorithm compatibility remains inSketchAlgorithmStrategy; subpopulation layout remains inHydraGroupingStrategy; equivalent logical algebra remains in the existing rewrite module; sharing and reuse remain in their current workload strategies; maintenance legality remains in lifecycle planning.The rewrite requires an outer cross-entity reduction over an inner label-preserving per-entity reduction, one measure per node, no
HAVING, and a registered algebraic law. It retains grouping, aliases, and accuracy, then accepts the result only if its output schema exactly matches the original.For
sum(count_over_time(...)), the rewrite takes the caller-visible name from the original output schema and inserts the required Float64 projection. This handles the PromQL front end's real empty output-name override instead of producingcol_Nand silently losing the candidate.The planner may declare how long selected summary state must remain available and account for that requirement in legality and cost. Cleanup timers, eviction thresholds, garbage collection, and engine-specific recovery workarounds are owned by runtime/storage lifecycle management and are not imported as planner strategies.
Window-framework selection belongs in #331's physical deployment planning. That work should compare an extensible family of implementations—including tumbling windows, sliding windows, PromSketch-style exponential-histogram windows, and other window frameworks—rather than expose a closed tumbling/sliding enum from lifecycle code. This PR therefore adds no window candidate types or enumeration API.
Before
The collapsible temporal/spatial pairs were represented as nested operators but never proposed as equivalent rewrites. The initial version of this PR also missed real PromQL's empty output alias, had schema-only fixture assertions, and conflated lowering with executable summary coverage.
After
sum(count_over_time(...))is discovered by default workload search.TimeRange, raw Scan child, output schema, and default strategy registration.avg_over_timeis documented as exact PassThrough, consistent with ASAPQuery's exact-only multi-stat fallback.Validation
cargo test -p asap-aware-mappingonmain— 240 passedcargo test -p asap-integration-tests --test promql_to_post_asap— 3 passedcargo test -p asap-devtools --bin dag_export post_asap_run_produces_both_summary_and_rewrite_replacements— passedcargo fmt --all -- --checkBase
This PR is based directly on
main; it has no dependency on #296 or the analytical-cost stack.