mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-03-21 15:45:01 +00:00
app/vmselect/promql: do not generate timestamps for NaN values in timestamp
function according to Prometheus logic
This commit is contained in:
parent
1e6ae9eff4
commit
67d44b0845
2 changed files with 15 additions and 1 deletions
|
@ -369,6 +369,17 @@ func TestExecSuccess(t *testing.T) {
|
||||||
resultExpected := []netstorage.Result{r}
|
resultExpected := []netstorage.Result{r}
|
||||||
f(q, resultExpected)
|
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.Run("time()/100", func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
q := `time()/100`
|
q := `time()/100`
|
||||||
|
|
|
@ -1121,9 +1121,12 @@ func transformTimestamp(tfa *transformFuncArg) ([]*timeseries, error) {
|
||||||
ts.MetricName.ResetMetricGroup()
|
ts.MetricName.ResetMetricGroup()
|
||||||
values := ts.Values
|
values := ts.Values
|
||||||
for i, t := range ts.Timestamps {
|
for i, t := range ts.Timestamps {
|
||||||
|
v := values[i]
|
||||||
|
if !math.IsNaN(v) {
|
||||||
values[i] = float64(t) / 1e3
|
values[i] = float64(t) / 1e3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return rvs, nil
|
return rvs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue