From e005f939fdfdd9776989e96039242356293ed68a Mon Sep 17 00:00:00 2001 From: Fabian Reinartz Date: Fri, 18 Sep 2015 16:49:32 +0200 Subject: [PATCH] Fix scalar construction in function --- promql/functions.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/promql/functions.go b/promql/functions.go index 321918eab..a817ff1fc 100644 --- a/promql/functions.go +++ b/promql/functions.go @@ -247,9 +247,15 @@ func funcRound(ev *evaluator, args Expressions) model.Value { func funcScalar(ev *evaluator, args Expressions) model.Value { v := ev.evalVector(args[0]) if len(v) != 1 { - return &model.Scalar{model.SampleValue(math.NaN()), ev.Timestamp} + return &model.Scalar{ + Value: model.SampleValue(math.NaN()), + Timestamp: ev.Timestamp, + } + } + return &model.Scalar{ + Value: model.SampleValue(v[0].Value), + Timestamp: ev.Timestamp, } - return &model.Scalar{model.SampleValue(v[0].Value), ev.Timestamp} } // === count_scalar(vector model.ValVector) model.SampleValue ===