mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 16:30:55 +01:00
app/vmselect: return NaN instead of 0 for empty value sets (#1660)
The change affects `count/stddev/stdvar_over_time` funcs and makes them to return NaN instead of zero when there is no datapoints in a time window. This is needed for improving compatibility with Prometheus. Signed-off-by: hagen1778 <roman@victoriametrics.com>
This commit is contained in:
parent
c8ac8f44b2
commit
72468c9d75
@ -1352,11 +1352,8 @@ func rollupCount(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) {
|
|
||||||
return nan
|
return nan
|
||||||
}
|
}
|
||||||
return 0
|
|
||||||
}
|
|
||||||
return float64(len(values))
|
return float64(len(values))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1372,11 +1369,8 @@ func rollupStdvar(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) {
|
|
||||||
return nan
|
return nan
|
||||||
}
|
}
|
||||||
return 0
|
|
||||||
}
|
|
||||||
if len(values) == 1 {
|
if len(values) == 1 {
|
||||||
// Fast path.
|
// Fast path.
|
||||||
return values[0]
|
return values[0]
|
||||||
|
Loading…
Reference in New Issue
Block a user