mirror of
https://github.com/prometheus/prometheus.git
synced 2025-08-05 13:47:10 +02:00
PromQL: Fix printing +min()
Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
This commit is contained in:
parent
3af0bdee68
commit
984c8de0da
@ -157,7 +157,15 @@ func (node *DurationExpr) String() string {
|
||||
expr = fmt.Sprintf("max(%s, %s)", node.LHS, node.RHS)
|
||||
case node.LHS == nil:
|
||||
// This is a unary duration expression.
|
||||
expr = fmt.Sprintf("%s%s", node.Op, node.RHS)
|
||||
switch node.Op {
|
||||
case SUB:
|
||||
expr = fmt.Sprintf("%s%s", node.Op, node.RHS)
|
||||
case ADD:
|
||||
expr = node.RHS.String()
|
||||
default:
|
||||
// This should never happen.
|
||||
panic(fmt.Sprintf("unexpected unary duration expression: %s", node.Op))
|
||||
}
|
||||
default:
|
||||
expr = fmt.Sprintf("%s %s %s", node.LHS, node.Op, node.RHS)
|
||||
}
|
||||
|
@ -199,6 +199,10 @@ func TestExprString(t *testing.T) {
|
||||
in: "foo offset +(5*2)",
|
||||
out: "foo offset (5 * 2)",
|
||||
},
|
||||
{
|
||||
in: "foo offset +min(10s, 20s)",
|
||||
out: "foo offset min(10s, 20s)",
|
||||
},
|
||||
{
|
||||
in: "foo offset -min(10s, 20s)",
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user