diff --git a/app/vmselect/promql/exec_test.go b/app/vmselect/promql/exec_test.go index d98901bc9..6364a5183 100644 --- a/app/vmselect/promql/exec_test.go +++ b/app/vmselect/promql/exec_test.go @@ -574,6 +574,30 @@ func TestExecSuccess(t *testing.T) { 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_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.Parallel() q := `clamp_min(time(), -time()+2500)` diff --git a/app/vmselect/promql/transform.go b/app/vmselect/promql/transform.go index c09b2e082..bc04a9f89 100644 --- a/app/vmselect/promql/transform.go +++ b/app/vmselect/promql/transform.go @@ -125,7 +125,8 @@ func newTransformFuncOneArg(tf func(v float64) float64) transformFunc { } 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 { if !keepMetricGroup { ts.MetricName.ResetMetricGroup()