mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
app/vmselect/promql: properly preserve metric name after applying functions in any case from transformFuncsKeepMetricGroup
This commit is contained in:
parent
6ddfb06b52
commit
2db685c19c
2 changed files with 26 additions and 1 deletions
|
@ -574,6 +574,30 @@ func TestExecSuccess(t *testing.T) {
|
||||||
resultExpected := []netstorage.Result{r}
|
resultExpected := []netstorage.Result{r}
|
||||||
f(q, resultExpected)
|
f(q, resultExpected)
|
||||||
})
|
})
|
||||||
|
t.Run(`clamp_max(alias(time(),"foobar"), 1400)`, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
q := `clamp_max(alias(time(), "foobar"), 1400)`
|
||||||
|
r := netstorage.Result{
|
||||||
|
MetricName: metricNameExpected,
|
||||||
|
Values: []float64{1000, 1200, 1400, 1400, 1400, 1400},
|
||||||
|
Timestamps: timestampsExpected,
|
||||||
|
}
|
||||||
|
r.MetricName.MetricGroup = []byte("foobar")
|
||||||
|
resultExpected := []netstorage.Result{r}
|
||||||
|
f(q, resultExpected)
|
||||||
|
})
|
||||||
|
t.Run(`CLAmp_MAx(alias(time(),"foobar"), 1400)`, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
q := `CLAmp_MAx(alias(time(), "foobar"), 1400)`
|
||||||
|
r := netstorage.Result{
|
||||||
|
MetricName: metricNameExpected,
|
||||||
|
Values: []float64{1000, 1200, 1400, 1400, 1400, 1400},
|
||||||
|
Timestamps: timestampsExpected,
|
||||||
|
}
|
||||||
|
r.MetricName.MetricGroup = []byte("foobar")
|
||||||
|
resultExpected := []netstorage.Result{r}
|
||||||
|
f(q, resultExpected)
|
||||||
|
})
|
||||||
t.Run("clamp_min(time(), -time()+3000)", func(t *testing.T) {
|
t.Run("clamp_min(time(), -time()+3000)", func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
q := `clamp_min(time(), -time()+2500)`
|
q := `clamp_min(time(), -time()+2500)`
|
||||||
|
|
|
@ -125,7 +125,8 @@ func newTransformFuncOneArg(tf func(v float64) float64) transformFunc {
|
||||||
}
|
}
|
||||||
|
|
||||||
func doTransformValues(arg []*timeseries, tf func(values []float64), fe *funcExpr) ([]*timeseries, error) {
|
func doTransformValues(arg []*timeseries, tf func(values []float64), fe *funcExpr) ([]*timeseries, error) {
|
||||||
keepMetricGroup := transformFuncsKeepMetricGroup[fe.Name]
|
name := strings.ToLower(fe.Name)
|
||||||
|
keepMetricGroup := transformFuncsKeepMetricGroup[name]
|
||||||
for _, ts := range arg {
|
for _, ts := range arg {
|
||||||
if !keepMetricGroup {
|
if !keepMetricGroup {
|
||||||
ts.MetricName.ResetMetricGroup()
|
ts.MetricName.ResetMetricGroup()
|
||||||
|
|
Loading…
Reference in a new issue