app/vmselect/promql: do not generate timestamps for NaN values in timestamp function according to Prometheus logic

This commit is contained in:
Aliaksandr Valialkin 2019-09-27 18:54:32 +03:00
parent 1e6ae9eff4
commit 67d44b0845
2 changed files with 15 additions and 1 deletions

View file

@ -369,6 +369,17 @@ func TestExecSuccess(t *testing.T) {
resultExpected := []netstorage.Result{r}
f(q, resultExpected)
})
t.Run("timestamp(time()>=1600)", func(t *testing.T) {
t.Parallel()
q := `timestamp(time()>=1600)`
r := netstorage.Result{
MetricName: metricNameExpected,
Values: []float64{nan, nan, nan, 1600, 1800, 2000},
Timestamps: timestampsExpected,
}
resultExpected := []netstorage.Result{r}
f(q, resultExpected)
})
t.Run("time()/100", func(t *testing.T) {
t.Parallel()
q := `time()/100`

View file

@ -1121,9 +1121,12 @@ func transformTimestamp(tfa *transformFuncArg) ([]*timeseries, error) {
ts.MetricName.ResetMetricGroup()
values := ts.Values
for i, t := range ts.Timestamps {
v := values[i]
if !math.IsNaN(v) {
values[i] = float64(t) / 1e3
}
}
}
return rvs, nil
}