Apply review feedback

Make the order of aggregate parts the same as before.

Make error message match.

Fix up benchmark for changes elsewhere.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
This commit is contained in:
Bryan Boreham 2025-07-11 14:03:38 +01:00
parent e4789cf89f
commit 75b72c2e42
2 changed files with 6 additions and 6 deletions

View File

@ -665,7 +665,7 @@ func BenchmarkParser(b *testing.B) {
expr, _ := parser.ParseExpr(c) expr, _ := parser.ParseExpr(c)
start, end := time.Now().Add(-time.Hour), time.Now() start, end := time.Now().Add(-time.Hour), time.Now()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
promql.PreprocessExpr(expr, start, end) promql.PreprocessExpr(expr, start, end, 0)
} }
}) })
} }

View File

@ -394,13 +394,13 @@ func ChildrenIter(node Node) func(func(Node) bool) {
} }
} }
case *AggregateExpr: case *AggregateExpr:
if n.Param != nil { if n.Expr != nil {
if !yield(n.Param) { if !yield(n.Expr) {
return return
} }
} }
if n.Expr != nil { if n.Param != nil {
yield(n.Expr) yield(n.Param)
} }
case *BinaryExpr: case *BinaryExpr:
if !yield(n.LHS) { if !yield(n.LHS) {
@ -426,7 +426,7 @@ func ChildrenIter(node Node) func(func(Node) bool) {
case *NumberLiteral, *StringLiteral, *VectorSelector: case *NumberLiteral, *StringLiteral, *VectorSelector:
// nothing to do // nothing to do
default: default:
panic(fmt.Errorf("promql.Children: unhandled node type %T", node)) panic(fmt.Errorf("promql.ChildrenIter: unhandled node type %T", node))
} }
} }
} }