app/vmselect/promql: do not return values from label_value() if the original time series has no values at the selected timestamps

This commit is contained in:
Aliaksandr Valialkin 2022-05-09 17:57:02 +03:00
parent e4bbcc29c2
commit a7f18f8cb2
No known key found for this signature in database
GPG Key ID: A72BEC6CD3D0DED1
3 changed files with 7 additions and 4 deletions

View File

@ -2069,7 +2069,7 @@ func TestExecSuccess(t *testing.T) {
t.Parallel()
q := `with (
x = (
label_set(time(), "foo", "123.456", "__name__", "aaa"),
label_set(time() > 1500, "foo", "123.456", "__name__", "aaa"),
label_set(-time(), "foo", "bar", "__name__", "bbb"),
label_set(-time(), "__name__", "bxs"),
label_set(-time(), "foo", "45", "bar", "xs"),
@ -2093,7 +2093,7 @@ func TestExecSuccess(t *testing.T) {
}
r2 := netstorage.Result{
MetricName: metricNameExpected,
Values: []float64{1123.456, 1323.456, 1523.456, 1723.456, 1923.456, 2123.456},
Values: []float64{nan, nan, nan, 1723.456, 1923.456, 2123.456},
Timestamps: timestampsExpected,
}
r2.MetricName.Tags = []storage.Tag{

View File

@ -1715,8 +1715,10 @@ func transformLabelValue(tfa *transformFuncArg) ([]*timeseries, error) {
v = nan
}
values := ts.Values
for i := range values {
values[i] = v
for i, vOrig := range values {
if !math.IsNaN(vOrig) {
values[i] = v
}
}
}
// Do not remove timeseries with only NaN values, so `default` could be applied to them:

View File

@ -17,6 +17,7 @@ The following tip changes can be tested by building VictoriaMetrics components f
* FEATURE: [vmctl](https://docs.victoriametrics.com/vmctl.html): add `influx-prometheus-mode` command-line flag, which allows to restore the original time series written from Prometheus into InfluxDB during data migration from InfluxDB to VictoriaMetrics. See [this feature request](https://github.com/VictoriaMetrics/vmctl/issues/8). Thanks to @mback2k for [the pull request](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/2545).
* BUGFIX: [MetricsQL](https://docs.victoriametrics.com/MetricsQL.html): do not return values from [label_value()](https://docs.victoriametrics.com/MetricsQL.html#label_value) functionif the original time series has no values at the selected timestamps.
## [v1.77.1](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.77.1)