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 {
format = "%s BY (%s)"
}
if node.KeepExtraLabels {
format += " KEEP_COMMON"
aggrString = fmt.Sprintf(format, aggrString, node.Grouping)
}
return fmt.Sprintf(format, aggrString, node.Grouping)
if node.KeepExtraLabels {
aggrString += " KEEP_COMMON"
}
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"}) KEEP_COMMON`,
},
{
in: `sum(task:errors:rate10s{job="s"}) WITHOUT (instance)`,
},