diff --git a/src/query/parser/promql/parse_test.go b/src/query/parser/promql/parse_test.go index 2c33852b03..b533d79044 100644 --- a/src/query/parser/promql/parse_test.go +++ b/src/query/parser/promql/parse_test.go @@ -77,7 +77,7 @@ func TestInvalidOffset(t *testing.T) { require.Error(t, err) } -func TestUnary(t *testing.T) { +func TestNegativeUnary(t *testing.T) { q := "-up" p, err := Parse(q, models.NewTagOptions()) require.NoError(t, err) @@ -93,6 +93,18 @@ func TestUnary(t *testing.T) { assert.Equal(t, edges[0].ChildID, parser.NodeID("1")) } +func TestPositiveUnary(t *testing.T) { + q := "+up" + p, err := Parse(q, models.NewTagOptions()) + require.NoError(t, err) + transforms, edges, err := p.DAG() + require.NoError(t, err) + assert.Len(t, transforms, 1) // "+" defaults to just a fetch operation + assert.Equal(t, transforms[0].Op.OpType(), functions.FetchType) + assert.Equal(t, transforms[0].ID, parser.NodeID("0")) + assert.Len(t, edges, 0) +} + func TestInvalidUnary(t *testing.T) { q := "*up" _, err := Parse(q, models.NewTagOptions()) diff --git a/src/query/parser/promql/types.go b/src/query/parser/promql/types.go index 5b29c05707..f617497846 100644 --- a/src/query/parser/promql/types.go +++ b/src/query/parser/promql/types.go @@ -248,7 +248,6 @@ func NewFunctionExpr( return p, true, err default: - // TODO: handle other types. return nil, false, fmt.Errorf("function not supported: %s", name) } }