app/vmselect/promql: do not return 0 value from sum_over_time(m[d]) when there are no samples on the given d window.

This aligns the behaviour of `sum_over_time()` with other `_over_time()` functions and with Prometheus behavior.
This commit is contained in:
Aliaksandr Valialkin 2020-12-02 13:11:32 +02:00
parent 490c70a958
commit def513355e

View File

@ -1142,10 +1142,10 @@ func rollupSum(rfa *rollupFuncArg) float64 {
// before calling rollup funcs. // before calling rollup funcs.
values := rfa.values values := rfa.values
if len(values) == 0 { if len(values) == 0 {
if math.IsNaN(rfa.prevValue) { // Do not take into account rfa.prevValue, since it may lead
return nan // to inconsistent results comparing to Prometheus on broken time series
} // with irregular data points.
return 0 return nan
} }
var sum float64 var sum float64
for _, v := range values { for _, v := range values {