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)
start, end := time.Now().Add(-time.Hour), time.Now()
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:
if n.Param != nil {
if !yield(n.Param) {
if n.Expr != nil {
if !yield(n.Expr) {
return
}
}
if n.Expr != nil {
yield(n.Expr)
if n.Param != nil {
yield(n.Param)
}
case *BinaryExpr:
if !yield(n.LHS) {
@ -426,7 +426,7 @@ func ChildrenIter(node Node) func(func(Node) bool) {
case *NumberLiteral, *StringLiteral, *VectorSelector:
// nothing to do
default:
panic(fmt.Errorf("promql.Children: unhandled node type %T", node))
panic(fmt.Errorf("promql.ChildrenIter: unhandled node type %T", node))
}
}
}