feat(promql): lower extra *_over_time reducers + sort family (#51) - #90
Merged
Merged
Conversation
The #51 long tail was three groups: extra range reducers, the sort family, and min_of/max_of. This lands the first two; min_of/max_of (n-ary scalar reducers, entangled with the unsupported step()/range() helpers) split to #89. Range reducers (asap-ir / asap-l2 / front end): - New per-series intents Last/First/Mad/TsOfMin/TsOfMax/TsOfFirst/TsOfLast- OverTime, wired through requires (TimeSeries), is_per_series, output_column, AggFunc, agg_func_to_intent, the RangelessRangeReduction guard, and both the matrix-selector (`lower_inner_call`) and sub-query (`range_fn_over_subquery`) dispatch paths. They slot into the same windowed per-series reduction shape as avg_over_time/max_over_time — a `TimeRange`-wrapped `Aggregate`. Sort family (front end only): - `is_sort_fn` / `walk_sort`: `sort`/`sort_desc(v)` → a bare `Sort` by sample value (asc/desc, no `Limit` — row-preserving); `sort_by_label[_desc](v, "l"…)` → one sort key per label, in argument order. The label args are seeded into the usage-derived schema by the existing `Sort.keys` binder path. Tests: conformance §U — each reducer → its per-series intent over a TimeRange; last_over_time under an outer sum; sort/sort_desc reorder by value with no Limit; sort_by_label's per-label keys + label seeding; min_of/max_of GAP. `unsupported_functions_are_rejected` repointed to step()/range()/ histogram_quantiles. Co-Authored-By: Claude Opus 4.8 <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 #51. Splits
min_of/max_ofto #89.What
The #51 long tail was three groups. This lands the two clean ones:
*_over_timereducers (21 corpus rejections):last_over_time,first_over_time,mad_over_time,ts_of_min_over_time,ts_of_max_over_time,ts_of_first_over_time,ts_of_last_over_time.sort,sort_desc,sort_by_label,sort_by_label_desc.How
Range reducers — new per-series intents
Last/First/Mad/TsOfMin/TsOfMax/TsOfFirst/TsOfLast-OverTime, wired throughrequires(TimeSeries),is_per_series,output_column, the L2AggFunc,agg_func_to_intent, theRangelessRangeReductionguard, and both dispatch paths — the matrix-selectorlower_inner_calland the sub-queryrange_fn_over_subquery(solast_over_time(rate(m[5m])[1h:1m])works too). They slot into the exact windowed per-series shape asavg_over_time/max_over_time: aTimeRange-wrappedAggregatewhose intent is label-preserving.Sort family — front-end only (the
Sortnode already exists).is_sort_fn/walk_sort:sort/sort_desc(v)→ a bareSortby sample value (asc/desc, noLimit— row-preserving reorder);sort_by_label[_desc](v, "l"…)→ one sort key per label in argument order. The label args are seeded into the usage-derived schema by the existingSort.keysbinder path.Scope:
min_of/max_ofdeferred to #89Per the parser these are n-ary scalar reducers (
Scalar…→Scalar), not vector element-wise as the issue guessed. In the corpus they're almost always nested withstep()/range()inside range/offsetpositions that are themselves unsupported (count_over_time(m[min_of(step()+1, 1h)])), and a non-constantmin_ofhas no home in the currentScalar(f64)leaf. Left rejected, pinned bymin_of_max_of_are_rejected__GAP, design in #89.Tests
Conformance §U:
TimeRange.sum by (job) (last_over_time(m[5m]))— per-series-then-cross-series nesting.sort/sort_descreorder by value with noLimit, correct direction.sort_by_label(v, "group", "instance", "job")— three keys in order, labels seeded.sort_by_label_descdescending;min_of/max_ofGAP.unsupported_functions_are_rejectedrepointed tostep()/range()/histogram_quantiles.Full workspace suite green; clippy clean.