From a14299805208ed7da43e482cf04055635bfb634a Mon Sep 17 00:00:00 2001 From: Charles Korn Date: Wed, 28 Jun 2023 15:11:01 +1000 Subject: [PATCH] Expand series set just once Signed-off-by: Charles Korn --- promql/engine.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/promql/engine.go b/promql/engine.go index 2702e1779..1d7483d2f 100644 --- a/promql/engine.go +++ b/promql/engine.go @@ -1826,16 +1826,17 @@ func (ev *evaluator) eval(expr parser.Expr) (parser.Value, storage.Warnings) { } func (ev *evaluator) evalTimestampFunctionOverVectorSelector(vs *parser.VectorSelector, call FunctionCall, e *parser.Call) (parser.Value, storage.Warnings) { + ws, err := checkAndExpandSeriesSet(ev.ctx, vs) + if err != nil { + ev.error(errWithWarnings{fmt.Errorf("expanding series: %w", err), ws}) + } + return ev.rangeEval(nil, func(v []parser.Value, _ [][]EvalSeriesHelper, enh *EvalNodeHelper) (Vector, storage.Warnings) { if vs.Timestamp != nil { // This is a special case only for "timestamp" since the offset // needs to be adjusted for every point. vs.Offset = time.Duration(enh.Ts-*vs.Timestamp) * time.Millisecond } - ws, err := checkAndExpandSeriesSet(ev.ctx, vs) - if err != nil { - ev.error(errWithWarnings{fmt.Errorf("expanding series: %w", err), ws}) - } vec := make(Vector, 0, len(vs.Series)) it := storage.NewMemoizedEmptyIterator(durationMilliseconds(ev.lookbackDelta)) var chkIter chunkenc.Iterator