parent
76eca03e90
commit
f889ac1140
|
@ -1146,6 +1146,11 @@ func TestServer_Query_Count(t *testing.T) {
|
||||||
command: fmt.Sprintf(`SELECT count(value) FROM db0.rp0.cpu WHERE time >= '%s'`, hour_ago.Format(time.RFC3339Nano)),
|
command: fmt.Sprintf(`SELECT count(value) FROM db0.rp0.cpu WHERE time >= '%s'`, hour_ago.Format(time.RFC3339Nano)),
|
||||||
exp: fmt.Sprintf(`{"results":[{"series":[{"name":"cpu","columns":["time","count"],"values":[["%s",1]]}]}]}`, hour_ago.Format(time.RFC3339Nano)),
|
exp: fmt.Sprintf(`{"results":[{"series":[{"name":"cpu","columns":["time","count"],"values":[["%s",1]]}]}]}`, hour_ago.Format(time.RFC3339Nano)),
|
||||||
},
|
},
|
||||||
|
&Query{
|
||||||
|
name: "selecting count(value) with filter that excludes all results should return 0",
|
||||||
|
command: fmt.Sprintf(`SELECT count(value) FROM db0.rp0.cpu WHERE value=100 AND time >= '%s'`, hour_ago.Format(time.RFC3339Nano)),
|
||||||
|
exp: fmt.Sprintf(`{"results":[{"series":[{"name":"cpu","columns":["time","count"],"values":[["%s",0]]}]}]}`, hour_ago.Format(time.RFC3339Nano)),
|
||||||
|
},
|
||||||
&Query{
|
&Query{
|
||||||
name: "selecting count(*) should error",
|
name: "selecting count(*) should error",
|
||||||
command: `SELECT count(*) FROM db0.rp0.cpu`,
|
command: `SELECT count(*) FROM db0.rp0.cpu`,
|
||||||
|
|
|
@ -250,10 +250,7 @@ func MapCount(input *MapInput) interface{} {
|
||||||
for range input.Items {
|
for range input.Items {
|
||||||
n++
|
n++
|
||||||
}
|
}
|
||||||
if n > 0 {
|
return n
|
||||||
return n
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type InterfaceValues []interface{}
|
type InterfaceValues []interface{}
|
||||||
|
|
Loading…
Reference in New Issue