app/vmselect/promql: remove empty timeseries left after topk call

This commit is contained in:
Aliaksandr Valialkin 2019-07-04 19:19:32 +03:00
parent 56c154f45b
commit 4dbd642c86
2 changed files with 16 additions and 1 deletions

View file

@ -431,7 +431,7 @@ func newAggrFuncTopK(isReverse bool) aggrFunc {
ts.Values[n] = nan
}
}
return rvs
return removeNaNs(rvs)
}
return aggrFuncExt(afe, args[1], &afa.ae.Modifier, true)
}

View file

@ -2473,6 +2473,21 @@ func TestExecSuccess(t *testing.T) {
resultExpected := []netstorage.Result{r1, r2}
f(q, resultExpected)
})
t.Run(`topk(1, nan_timeseries)`, func(t *testing.T) {
t.Parallel()
q := `topk(1, label_set(NaN, "foo", "bar") or label_set(time()/150, "baz", "sss")) default 0`
r1 := netstorage.Result{
MetricName: metricNameExpected,
Values: []float64{6.666666666666667, 8, 9.333333333333334, 10.666666666666666, 12, 13.333333333333334},
Timestamps: timestampsExpected,
}
r1.MetricName.Tags = []storage.Tag{{
Key: []byte("baz"),
Value: []byte("sss"),
}}
resultExpected := []netstorage.Result{r1}
f(q, resultExpected)
})
t.Run(`topk(2)`, func(t *testing.T) {
t.Parallel()
q := `sort(topk(2, label_set(10, "foo", "bar") or label_set(time()/150, "baz", "sss")))`