Fix missing printed keep_common without grouping.

This commit is contained in:
Julius Volz 2016-04-15 19:48:17 +02:00
parent 096a2ef200
commit 6ac39700ea
2 changed files with 7 additions and 4 deletions

View file

@ -143,10 +143,10 @@ func (node *AggregateExpr) String() string {
} else { } else {
format = "%s BY (%s)" format = "%s BY (%s)"
} }
if node.KeepExtraLabels { aggrString = fmt.Sprintf(format, aggrString, node.Grouping)
format += " KEEP_COMMON" }
} if node.KeepExtraLabels {
return fmt.Sprintf(format, aggrString, node.Grouping) aggrString += " KEEP_COMMON"
} }
return aggrString return aggrString
} }

View file

@ -30,6 +30,9 @@ func TestExprString(t *testing.T) {
{ {
in: `sum(task:errors:rate10s{job="s"}) BY (code) KEEP_COMMON`, in: `sum(task:errors:rate10s{job="s"}) BY (code) KEEP_COMMON`,
}, },
{
in: `sum(task:errors:rate10s{job="s"}) KEEP_COMMON`,
},
{ {
in: `sum(task:errors:rate10s{job="s"}) WITHOUT (instance)`, in: `sum(task:errors:rate10s{job="s"}) WITHOUT (instance)`,
}, },