Skip to content

Commit

Permalink
proxystorage: fix avg bug
Browse files Browse the repository at this point in the history
  • Loading branch information
sundy-li authored and jacksontj committed Mar 4, 2020
1 parent dc00705 commit c39aef6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/proxystorage/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,15 +299,15 @@ func (p *ProxyStorage) NodeReplacer(ctx context.Context, s *promql.EvalStmt, nod
Op: promql.ItemDIV,
LHS: &promql.AggregateExpr{
Op: promql.ItemSum,
Expr: n.Expr,
Expr: CloneExpr(n.Expr),
Param: n.Param,
Grouping: n.Grouping,
Without: n.Without,
},

RHS: &promql.AggregateExpr{
Op: promql.ItemCount,
Expr: n.Expr,
Expr: CloneExpr(n.Expr),
Param: n.Param,
Grouping: n.Grouping,
Without: n.Without,
Expand Down
5 changes: 5 additions & 0 deletions pkg/proxystorage/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,8 @@ func (f *BooleanFinder) Visit(node promql.Node, _ []promql.Node) (promql.Visitor
}
return f, nil
}

func CloneExpr(expr promql.Expr) (newExpr promql.Expr) {
newExpr, _ = promql.ParseExpr(expr.String())
return
}

0 comments on commit c39aef6

Please sign in to comment.