diff --git a/app/vmselect/promql/exec_test.go b/app/vmselect/promql/exec_test.go index 57d381502..8003ba342 100644 --- a/app/vmselect/promql/exec_test.go +++ b/app/vmselect/promql/exec_test.go @@ -6132,7 +6132,7 @@ func TestExecSuccess(t *testing.T) { q := `interpolate(time() < 1300)` r1 := netstorage.Result{ MetricName: metricNameExpected, - Values: []float64{1000, 1200, 1200, 1200, 1200, 1200}, + Values: []float64{1000, 1200, nan, nan, nan, nan}, Timestamps: timestampsExpected, } resultExpected := []netstorage.Result{r1} @@ -6143,7 +6143,18 @@ func TestExecSuccess(t *testing.T) { q := `interpolate(time() > 1500)` r1 := netstorage.Result{ MetricName: metricNameExpected, - Values: []float64{1600, 1600, 1600, 1600, 1800, 2000}, + Values: []float64{nan, nan, nan, 1600, 1800, 2000}, + Timestamps: timestampsExpected, + } + resultExpected := []netstorage.Result{r1} + f(q, resultExpected) + }) + t.Run(`interpolate(tail_head_and_middle)`, func(t *testing.T) { + t.Parallel() + q := `interpolate(time() > 1100 and time() < 1300 default time() > 1700 and time() < 1900)` + r1 := netstorage.Result{ + MetricName: metricNameExpected, + Values: []float64{nan, 1200, 1400, 1600, 1800, nan}, Timestamps: timestampsExpected, } resultExpected := []netstorage.Result{r1} diff --git a/app/vmselect/promql/transform.go b/app/vmselect/promql/transform.go index 62e5cd92e..16c6cda2b 100644 --- a/app/vmselect/promql/transform.go +++ b/app/vmselect/promql/transform.go @@ -1165,7 +1165,8 @@ func transformInterpolate(tfa *transformFuncArg) ([]*timeseries, error) { } rvs := args[0] for _, ts := range rvs { - values := ts.Values + values := skipLeadingNaNs(ts.Values) + values = skipTrailingNaNs(values) if len(values) == 0 { continue } diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index fa6f9c221..76a157f7d 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -22,6 +22,7 @@ The following tip changes can be tested by building VictoriaMetrics components f * BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): fix [Azure service discovery](https://docs.victoriametrics.com/sd_configs.html#azure_sd_configs) inside [Azure Container App](https://learn.microsoft.com/en-us/azure/container-apps/overview). See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3830). Thanks to @MattiasAng for the fix! * BUGFIX: prevent from possible data ingestion slowdown and query performance slowdown during [background merges of big parts](https://docs.victoriametrics.com/#storage) on systems with small number of CPU cores (1 or 2 CPU cores). The issue has been introduced in [v1.85.0](https://docs.victoriametrics.com/CHANGELOG.html#v1850) when implementing [this feature](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3337). See also [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3790). * BUGFIX: properly parse timestamps in milliseconds when [ingesting data via OpenTSDB telnet put protocol](https://docs.victoriametrics.com/#sending-data-via-telnet-put-protocol). Previously timestamps in milliseconds were mistakenly multiplied by 1000. Thanks to @Droxenator for the [pull request](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/3810). +* BUGFIX: [MetricsQL](https://docs.victoriametrics.com/MetricsQL.html): do not add extrapolated points outside the real points when using [interpolate()](https://docs.victoriametrics.com/MetricsQL.html#interpolate) function. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3816). ## [v1.87.1](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.87.1)