Fix time() behavior.

time() should return the timestamp for which the query is executed, not
the actual current time.

Change-Id: I430a45cabad7785cd58f95b1028a71dff4c87710
pull/413/head
Julius Volz 2014-07-28 18:10:11 +02:00 committed by Bjoern Rabenstein
parent c5984f1818
commit 00b9489f1c
2 changed files with 7 additions and 1 deletions

View File

@ -75,7 +75,7 @@ func (function *Function) CheckArgTypes(args []Node) error {
// === time() clientmodel.SampleValue ===
func timeImpl(timestamp clientmodel.Timestamp, view *viewAdapter, args []Node) interface{} {
return clientmodel.SampleValue(time.Now().Unix())
return clientmodel.SampleValue(timestamp.Unix())
}
// === delta(matrix MatrixNode, isCounter ScalarNode) Vector ===

View File

@ -496,6 +496,12 @@ func TestExpressions(t *testing.T) {
fullRanges: 2,
intervalRanges: 0,
},
{
expr: `time()`,
output: []string{`scalar: 3000 @[%v]`},
fullRanges: 0,
intervalRanges: 0,
},
}
tieredStorage, closer := newTestStorage(t)