From 6d3e05469211e0896efebf593cfd3af9003fa364 Mon Sep 17 00:00:00 2001 From: Julius Volz Date: Thu, 10 Sep 2015 01:37:05 +0200 Subject: [PATCH] Fix bool modifier in recording rules and printing. Fixes https://github.com/prometheus/prometheus/issues/1065 --- promql/printer.go | 7 ++++++- promql/printer_test.go | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/promql/printer.go b/promql/printer.go index 99025ccd9..44b05f149 100644 --- a/promql/printer.go +++ b/promql/printer.go @@ -146,6 +146,11 @@ func (node *AggregateExpr) String() string { } func (node *BinaryExpr) String() string { + returnBool := "" + if node.ReturnBool { + returnBool = " BOOL" + } + matching := "" vm := node.VectorMatching if vm != nil && len(vm.On) > 0 { @@ -157,7 +162,7 @@ func (node *BinaryExpr) String() string { matching += fmt.Sprintf(" GROUP_RIGHT(%s)", vm.Include) } } - return fmt.Sprintf("%s %s%s %s", node.LHS, node.Op, matching, node.RHS) + return fmt.Sprintf("%s %s%s%s %s", node.LHS, node.Op, returnBool, matching, node.RHS) } func (node *Call) String() string { diff --git a/promql/printer_test.go b/promql/printer_test.go index 9a86c96db..8b3f4154e 100644 --- a/promql/printer_test.go +++ b/promql/printer_test.go @@ -30,6 +30,9 @@ func TestExprString(t *testing.T) { { in: `sum(task:errors:rate10s{job="s"}) BY (code) KEEP_COMMON`, }, + { + in: `up > BOOL 0`, + }, } for _, test := range inputs {