count with fill(none) will drop 0 valued intervals
parent
50176c4c86
commit
b7000c80dd
|
@ -3,6 +3,7 @@
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
### Bugfixes
|
### Bugfixes
|
||||||
|
- [#5042](https://github.com/influxdb/influxdb/issues/5042): Count with fill(none) will drop 0 valued intervals.
|
||||||
- [#5016](https://github.com/influxdb/influxdb/pull/5016): Don't panic if Meta data directory not writable. Thanks @oiooj
|
- [#5016](https://github.com/influxdb/influxdb/pull/5016): Don't panic if Meta data directory not writable. Thanks @oiooj
|
||||||
- [#5059](https://github.com/influxdb/influxdb/pull/5059): Fix unmarshal of database error by client code. Thanks @farshidtz
|
- [#5059](https://github.com/influxdb/influxdb/pull/5059): Fix unmarshal of database error by client code. Thanks @farshidtz
|
||||||
- [#4940](https://github.com/influxdb/influxdb/pull/4940): Fix distributed aggregate query query error. Thanks @li-ang
|
- [#4940](https://github.com/influxdb/influxdb/pull/4940): Fix distributed aggregate query query error. Thanks @li-ang
|
||||||
|
|
|
@ -4377,6 +4377,24 @@ func TestServer_Query_Fill(t *testing.T) {
|
||||||
exp: `{"results":[{"series":[{"name":"fills","columns":["time","mean"],"values":[["2009-11-10T23:00:00Z",4],["2009-11-10T23:00:05Z",4],["2009-11-10T23:00:10Z",null],["2009-11-10T23:00:15Z",10]]}]}]}`,
|
exp: `{"results":[{"series":[{"name":"fills","columns":["time","mean"],"values":[["2009-11-10T23:00:00Z",4],["2009-11-10T23:00:05Z",4],["2009-11-10T23:00:10Z",null],["2009-11-10T23:00:15Z",10]]}]}]}`,
|
||||||
params: url.Values{"db": []string{"db0"}},
|
params: url.Values{"db": []string{"db0"}},
|
||||||
},
|
},
|
||||||
|
&Query{
|
||||||
|
name: "fill defaults to 0 for count",
|
||||||
|
command: `select count(val) from fills where time >= '2009-11-10T23:00:00Z' and time < '2009-11-10T23:00:20Z' group by time(5s)`,
|
||||||
|
exp: `{"results":[{"series":[{"name":"fills","columns":["time","count"],"values":[["2009-11-10T23:00:00Z",2],["2009-11-10T23:00:05Z",1],["2009-11-10T23:00:10Z",0],["2009-11-10T23:00:15Z",1]]}]}]}`,
|
||||||
|
params: url.Values{"db": []string{"db0"}},
|
||||||
|
},
|
||||||
|
&Query{
|
||||||
|
name: "fill none drops 0s for count",
|
||||||
|
command: `select count(val) from fills where time >= '2009-11-10T23:00:00Z' and time < '2009-11-10T23:00:20Z' group by time(5s) fill(none)`,
|
||||||
|
exp: `{"results":[{"series":[{"name":"fills","columns":["time","count"],"values":[["2009-11-10T23:00:00Z",2],["2009-11-10T23:00:05Z",1],["2009-11-10T23:00:15Z",1]]}]}]}`,
|
||||||
|
params: url.Values{"db": []string{"db0"}},
|
||||||
|
},
|
||||||
|
&Query{
|
||||||
|
name: "fill previous overwrites 0s for count",
|
||||||
|
command: `select count(val) from fills where time >= '2009-11-10T23:00:00Z' and time < '2009-11-10T23:00:20Z' group by time(5s) fill(previous)`,
|
||||||
|
exp: `{"results":[{"series":[{"name":"fills","columns":["time","count"],"values":[["2009-11-10T23:00:00Z",2],["2009-11-10T23:00:05Z",1],["2009-11-10T23:00:10Z",1],["2009-11-10T23:00:15Z",1]]}]}]}`,
|
||||||
|
params: url.Values{"db": []string{"db0"}},
|
||||||
|
},
|
||||||
}...)
|
}...)
|
||||||
|
|
||||||
for i, query := range test.queries {
|
for i, query := range test.queries {
|
||||||
|
|
|
@ -322,6 +322,7 @@ func (e *AggregateExecutor) processFill(results [][]interface{}) [][]interface{}
|
||||||
return results
|
return results
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isCount := e.stmt.HasSimpleCount()
|
||||||
if e.stmt.Fill == influxql.NoFill {
|
if e.stmt.Fill == influxql.NoFill {
|
||||||
// remove any rows that have even one nil value. This one is tricky because they could have multiple
|
// remove any rows that have even one nil value. This one is tricky because they could have multiple
|
||||||
// aggregates, but this option means that any row that has even one nil gets purged.
|
// aggregates, but this option means that any row that has even one nil gets purged.
|
||||||
|
@ -330,7 +331,7 @@ func (e *AggregateExecutor) processFill(results [][]interface{}) [][]interface{}
|
||||||
hasNil := false
|
hasNil := false
|
||||||
// start at 1 because the first value is always time
|
// start at 1 because the first value is always time
|
||||||
for j := 1; j < len(vals); j++ {
|
for j := 1; j < len(vals); j++ {
|
||||||
if vals[j] == nil {
|
if vals[j] == nil || (isCount && isZero(vals[j])) {
|
||||||
hasNil = true
|
hasNil = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -342,7 +343,6 @@ func (e *AggregateExecutor) processFill(results [][]interface{}) [][]interface{}
|
||||||
return newResults
|
return newResults
|
||||||
}
|
}
|
||||||
|
|
||||||
isCount := e.stmt.HasSimpleCount()
|
|
||||||
// They're either filling with previous values or a specific number
|
// They're either filling with previous values or a specific number
|
||||||
for i, vals := range results {
|
for i, vals := range results {
|
||||||
// start at 1 because the first value is always time
|
// start at 1 because the first value is always time
|
||||||
|
|
Loading…
Reference in New Issue