diff --git a/cmd/influxd/server_integration_test.go b/cmd/influxd/server_integration_test.go index 95f1b53b21..a502ac7bb8 100644 --- a/cmd/influxd/server_integration_test.go +++ b/cmd/influxd/server_integration_test.go @@ -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`, diff --git a/influxql/engine.go b/influxql/engine.go index 7134091b29..0764cd6d47 100644 --- a/influxql/engine.go +++ b/influxql/engine.go @@ -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