Browse Source

fix subquery with offset conversion to string (#6373)

Signed-off-by: Bartosz Jakubski <b.jakubski@gmail.com>
pull/6380/head^2
Bartosz Jakubski 5 years ago committed by Brian Brazil
parent
commit
80ba03c67d
  1. 6
      promql/printer.go
  2. 3
      promql/printer_test.go

6
promql/printer.go

@ -128,7 +128,11 @@ func (node *SubqueryExpr) String() string {
if node.Step != 0 {
step = model.Duration(node.Step).String()
}
return fmt.Sprintf("%s[%s:%s]", node.Expr.String(), model.Duration(node.Range), step)
offset := ""
if node.Offset != time.Duration(0) {
offset = fmt.Sprintf(" offset %s", model.Duration(node.Offset))
}
return fmt.Sprintf("%s[%s:%s]%s", node.Expr.String(), model.Duration(node.Range), step, offset)
}
func (node *NumberLiteral) String() string {

3
promql/printer_test.go

@ -83,6 +83,9 @@ func TestExprString(t *testing.T) {
{
in: `a[5m] offset 1m`,
},
{
in: `a[1h:5m] offset 1m`,
},
{
in: `{__name__="a"}`,
},

Loading…
Cancel
Save