Merge pull request #16352 from NeerajGartia21/promql/subquery_patch

[BUG] PromQL: Return early when `endtime` < `startime`
This commit is contained in:
Björn Rabenstein 2025-04-16 01:00:19 +02:00 committed by GitHub
commit ba8609fbd0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

View file

@ -1582,6 +1582,11 @@ func (ev *evaluator) eval(ctx context.Context, expr parser.Expr) (parser.Value,
if err := contextDone(ctx, "expression evaluation"); err != nil {
ev.error(err)
}
if ev.endTimestamp < ev.startTimestamp {
return Matrix{}, nil
}
numSteps := int((ev.endTimestamp-ev.startTimestamp)/ev.interval) + 1
// Create a new span to help investigate inner evaluation performances.

View file

@ -150,3 +150,10 @@ eval instant at 10m increase(native_histogram[10m:3m])
# by the sub-query multiple times.
eval instant at 10m increase(native_histogram[10m:15s])
{} {{count:30.769230769230766 sum:30.769230769230766}}
# When range < resolution and the first evaluation time is out of range.
load 5m
foo 3+0x10
eval instant at 12m min_over_time((topk(1, foo))[1m:5m])
#empty