feat(promql): range-vector functions over a sub-query argument (#55) - #76
Merged
Merged
Conversation
Generalizes the `*_over_time`-over-sub-query support (#42) to the whole range-vector family: `rate`/`irate`/`increase` and the counter-derivatives (`changes`/`delta`/`idelta`/`deriv`/`resets`/`predict_linear`/ `double_exponential_smoothing`). `f(<inst>[range:res])` now lowers to a per-series `Aggregate{[f]}` directly over the `PromQLSubquery`. Front end: `walk_call` routes any range function whose matrix argument is a sub-query through a unified `range_fn_over_subquery` (rate/increase read the window from the sub-query's own range; predict_linear/double_exp thread their scalar params; quantile_over_time reads φ from arg 0). Converter: a `PromQLSubquery` input is the range context, so (1) no `TimeRange` is synthesized over it — `rate(sub)` would otherwise get a spurious TimeRange from its carried window — and (2) the #71 counter- derivative range-less guard correctly does not fire when the input is a sub-query. Flips `counter_derivative_over_a_subquery_is_rejected__GAP` into passing conformance tests (per-series intent directly over the Subquery, no TimeRange; scalar params carried). Normal matrix forms (`rate(m[5m])`, `changes(m[15m])`) unchanged. Full workspace suite green; clippy clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Closes #55. Generalizes the
*_over_time-over-sub-query support (#42) to the whole range-vector family:rate/irate/increaseand the counter-derivatives (changes/delta/idelta/deriv/resets/predict_linear/double_exponential_smoothing).Before / after
rate(sum(m)[5m:]),changes(rate(m[5m])[1h:]), etc. were rejected (expected a range-vector (matrix) argument). Now each lowers to a per-seriesAggregate{[f]}directly over theSubquery— the sub-query is the range context, so there is no separateTimeRange.How
promql.rs):walk_callroutes any range function whose matrix arg is a sub-query through a unifiedrange_fn_over_subquery.rate/increaseread the window from the sub-query's own range;predict_linear/double_expthread their scalar params;quantile_over_timereads φ from arg 0.l2/lower.rs): aPromQLSubqueryinput is the range context, so (1) noTimeRangeis synthesized over it (rate(sub)would otherwise get a spurious TimeRange from its carried window), and (2) the L2 hardening: counter-derivative intent can be emitted range-less if it reaches the converter without a Window #71 counter-derivative range-less guard correctly does not fire when the input is a sub-query.Verified
rate(sum(m)[5m:])→Aggregate{Rate} over Subquery{5m}(no double range);changes(rate(m[5m])[1h:])→Aggregate{Changes} over Subquery{1h} over Aggregate{Rate} over TimeRange{5m}; params carried for predict_linear/double_exp. Normal matrix forms unchanged. Flipscounter_derivative_over_a_subquery_is_rejected__GAPinto passing conformance tests. Full suite green (29 binaries), clippy clean.🤖 Generated with Claude Code