diff --git a/app/vmselect/promql/exec_test.go b/app/vmselect/promql/exec_test.go index f05b043ace..af5d976d8d 100644 --- a/app/vmselect/promql/exec_test.go +++ b/app/vmselect/promql/exec_test.go @@ -4836,7 +4836,7 @@ func TestExecSuccess(t *testing.T) { q := `integrate(time()/1e3)` r := netstorage.Result{ MetricName: metricNameExpected, - Values: []float64{180, 220.00000000000003, 259.99999999999994, 300, 340.00000000000006, 380}, + Values: []float64{160, 200, 240, 280, 320, 360}, Timestamps: timestampsExpected, } resultExpected := []netstorage.Result{r} diff --git a/app/vmselect/promql/rollup.go b/app/vmselect/promql/rollup.go index a271757b18..16087c052e 100644 --- a/app/vmselect/promql/rollup.go +++ b/app/vmselect/promql/rollup.go @@ -1710,7 +1710,7 @@ func rollupIntegrate(rfa *rollupFuncArg) float64 { for i, v := range values { timestamp := timestamps[i] dt := float64(timestamp-prevTimestamp) / 1e3 - sum += 0.5 * (v + prevValue) * dt + sum += prevValue * dt prevTimestamp = timestamp prevValue = v } diff --git a/app/vmselect/promql/rollup_test.go b/app/vmselect/promql/rollup_test.go index d8080685a8..aef7c335f6 100644 --- a/app/vmselect/promql/rollup_test.go +++ b/app/vmselect/promql/rollup_test.go @@ -431,7 +431,7 @@ func TestRollupNewRollupFuncSuccess(t *testing.T) { f("stdvar_over_time", 945.7430555555555) f("first_over_time", 123) f("last_over_time", 34) - f("integrate", 5.4705) + f("integrate", 5.237) f("distinct_over_time", 8) f("ideriv", 0) f("decreases_over_time", 5) @@ -970,7 +970,7 @@ func TestRollupFuncsNoWindow(t *testing.T) { } rc.Timestamps = getTimestamps(rc.Start, rc.End, rc.Step) values := rc.Do(nil, testValues, testTimestamps) - valuesExpected := []float64{nan, 1.526, 2.2795, 1.325, 0.34} + valuesExpected := []float64{nan, 2.064, 1.677, 1.156, 0.34} timestampsExpected := []int64{0, 40, 80, 120, 160} testRowsEqual(t, values, rc.Timestamps, valuesExpected, timestampsExpected) })