From ca0db3da890d5d485a2192ada2a9988dedf18491 Mon Sep 17 00:00:00 2001 From: Kebe Date: Mon, 18 Nov 2019 17:34:40 +0800 Subject: [PATCH] > remove useless where. --- storage/spl_engine.go | 2 +- storage/spl_engine_test.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/storage/spl_engine.go b/storage/spl_engine.go index 57adad8..85e4af9 100644 --- a/storage/spl_engine.go +++ b/storage/spl_engine.go @@ -31,7 +31,7 @@ func MakeSPL(query *prompb.Query, c RemoteClient, index string) (string, error) CommonMetricValue, index, metricName, step, ls) for _, m := range query.Matchers { if m.Name == "__name__" { - m.Name = "metric_name" + continue } switch m.Type { case prompb.LabelMatcher_RE: diff --git a/storage/spl_engine_test.go b/storage/spl_engine_test.go index 4134de5..cd3a601 100644 --- a/storage/spl_engine_test.go +++ b/storage/spl_engine_test.go @@ -45,7 +45,7 @@ func TestMakeSPL(t *testing.T) { labels: []string{"test"}, }, "test", - `| mstats latest(_value) as ropee_metric_value where index=test AND metric_name=test span=10s by metric_name test| where metric_name="test"| rename metric_name as ropee_metric_name`, + `| mstats latest(_value) as ropee_metric_value where index=test AND metric_name=test span=10s by metric_name test| rename metric_name as ropee_metric_name`, nil, }, { @@ -68,7 +68,7 @@ func TestMakeSPL(t *testing.T) { labels: []string{"test"}, }, "test", - `| mstats latest(_value) as ropee_metric_value where index=test AND metric_name=test span=100s by metric_name test| where metric_name="test"| rename metric_name as ropee_metric_name`, + `| mstats latest(_value) as ropee_metric_value where index=test AND metric_name=test span=100s by metric_name test| rename metric_name as ropee_metric_name`, nil, }, { @@ -91,7 +91,7 @@ func TestMakeSPL(t *testing.T) { labels: []string{"test", "q"}, }, "test", - `| mstats latest(_value) as ropee_metric_value where index=test AND metric_name=test span=10s by metric_name test q| where metric_name="test"| rename metric_name as ropee_metric_name`, + `| mstats latest(_value) as ropee_metric_value where index=test AND metric_name=test span=10s by metric_name test q| rename metric_name as ropee_metric_name`, nil, }, { @@ -129,7 +129,7 @@ func TestMakeSPL(t *testing.T) { labels: []string{"test1", "test2", "test3"}, }, "test", - `| mstats latest(_value) as ropee_metric_value where index=test AND metric_name=test span=10s by metric_name test1 test2 test3| where metric_name="test"| where test1!="test"| regex test2=".*test$"| regex test3!=".*test$"| rename metric_name as ropee_metric_name`, + `| mstats latest(_value) as ropee_metric_value where index=test AND metric_name=test span=10s by metric_name test1 test2 test3| where test1!="test"| regex test2=".*test$"| regex test3!=".*test$"| rename metric_name as ropee_metric_name`, nil, }, {