From 3880a86c9cf931ee016e6f082f2a04b6ab4c0e4b Mon Sep 17 00:00:00 2001 From: Julius Volz Date: Mon, 25 Mar 2013 12:14:48 +0100 Subject: [PATCH] In case of empty query results, return an empty matrix. --- rules/ast/ast.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rules/ast/ast.go b/rules/ast/ast.go index 30b40755d..182ffc7da 100644 --- a/rules/ast/ast.go +++ b/rules/ast/ast.go @@ -257,16 +257,18 @@ func labelsToKey(labels model.Metric) string { func EvalVectorInstant(node VectorNode, timestamp time.Time) (vector Vector) { viewAdapter, err := viewAdapterForInstantQuery(node, timestamp) if err != nil { - // TODO: propagate errors. return } return node.Eval(×tamp, viewAdapter) } func EvalVectorRange(node VectorNode, start time.Time, end time.Time, interval time.Duration) (matrix Matrix, err error) { + // Explicitly initialize to an empty matrix since a nil Matrix encodes to + // null in JSON. + matrix = Matrix{} + viewAdapter, err := viewAdapterForRangeQuery(node, start, end, interval) if err != nil { - // TODO: propagate errors. return } // TODO implement watchdog timer for long-running queries.