handle aggregations with 0 intervals

pull/2547/head
ben hockey 2015-05-12 10:25:49 -05:00
parent 0e51843c59
commit 8e02595b3e
2 changed files with 10 additions and 1 deletions

View File

@ -673,6 +673,12 @@ func runTestsData(t *testing.T, testName string, nodes Cluster, database, retent
queryDb: "%DB%",
expected: `{"results":[{"series":[{"name":"cpu","columns":["time","value"],"values":[["2000-01-01T00:00:10Z",30]]}]}]}`,
},
{
name: "aggregation with no interval",
query: `SELECT count(value) FROM cpu WHERE time = '2000-01-01 00:00:00'`,
queryDb: "%DB%",
expected: `{"results":[{"series":[{"name":"cpu","columns":["time","count"],"values":[["2000-01-01T00:00:00Z",2]]}]}]}`,
},
{
name: "sum aggregation",
query: `SELECT SUM(value) FROM cpu WHERE time >= '2000-01-01 00:00:05' AND time <= '2000-01-01T00:00:10Z' GROUP BY time(10s), region`,

View File

@ -135,7 +135,10 @@ func (m *MapReduceJob) Execute(out chan *Row, filterEmptyResults bool) {
resultValues := make([][]interface{}, pointCountInResult)
// ensure that the start time for the results is on the start of the window
startTimeBucket := m.TMin / m.interval * m.interval
startTimeBucket := m.TMin
if m.interval > 0 {
startTimeBucket = startTimeBucket / m.interval * m.interval
}
for i, _ := range resultValues {
var t int64