From 3d10ef084b8980aaf765fdc7456d6d3946cfa222 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Mon, 18 Jul 2022 14:21:53 +0300 Subject: [PATCH] app/vmselect/promql/transform.go: reuse evalNumber() function for constructing timezone_offset() results --- app/vmselect/promql/transform.go | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/app/vmselect/promql/transform.go b/app/vmselect/promql/transform.go index a893e217e..c83616dd1 100644 --- a/app/vmselect/promql/transform.go +++ b/app/vmselect/promql/transform.go @@ -2183,17 +2183,13 @@ func transformTimezoneOffset(tfa *transformFuncArg) ([]*timeseries, error) { return nil, fmt.Errorf("cannot load timezone %q: %w", tzString, err) } - var ts timeseries - ts.denyReuse = true - timestamps := tfa.ec.getSharedTimestamps() - values := make([]float64, len(timestamps)) - for i, v := range timestamps { - _, offset := time.Unix(v/1000, 0).In(loc).Zone() - values[i] = float64(offset) + tss := evalNumber(tfa.ec, nan) + ts := tss[0] + for i, timestamp := range ts.Timestamps { + _, offset := time.Unix(timestamp/1000, 0).In(loc).Zone() + ts.Values[i] = float64(offset) } - ts.Values = values - ts.Timestamps = timestamps - return []*timeseries{&ts}, nil + return tss, nil } func transformTime(tfa *transformFuncArg) ([]*timeseries, error) {