diff --git a/CHANGELOG.md b/CHANGELOG.md index 993711963d0..bfc40a3633d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ ### Features - [#1902](https://github.com/influxdb/influxdb/pull/1902): Enforce retention policies to have a minimum duration. - [#1906](https://github.com/influxdb/influxdb/pull/1906): Add show servers to query language. +- [#1925](https://github.com/influxdb/influxdb/pull/1925): Add `fill(none)`, `fill(previous)`, and `fill()` to queries. ## v0.9.0-rc10 [2015-03-09] diff --git a/cmd/influxd/server_integration_test.go b/cmd/influxd/server_integration_test.go index 1024da4f4b3..137017cacf8 100644 --- a/cmd/influxd/server_integration_test.go +++ b/cmd/influxd/server_integration_test.go @@ -495,6 +495,34 @@ func runTestsData(t *testing.T, testName string, nodes Cluster, database, retent expected: `{"results":[{"series":[{"name":"limit","columns":["time","foo"]}]}]}`, }, + // Fill tests + { + name: "fill with value", + write: `{"database" : "%DB%", "retentionPolicy" : "%RP%", "points": [ + {"name": "fills", "timestamp": "2009-11-10T23:00:02Z","fields": {"val": 3}}, + {"name": "fills", "timestamp": "2009-11-10T23:00:03Z","fields": {"val": 5}}, + {"name": "fills", "timestamp": "2009-11-10T23:00:06Z","fields": {"val": 4}}, + {"name": "fills", "timestamp": "2009-11-10T23:00:16Z","fields": {"val": 10}} + ]}`, + query: `select mean(val) from "%DB%"."%RP%".fills where time >= '2009-11-10T23:00:00Z' and time < '2009-11-10T23:00:20Z' group by time(5s) fill(1)`, + expected: `{"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",1],["2009-11-10T23:00:15Z",10]]}]}]}`, + }, + { + name: "fill with previous", + query: `select mean(val) from "%DB%"."%RP%".fills where time >= '2009-11-10T23:00:00Z' and time < '2009-11-10T23:00:20Z' group by time(5s) fill(previous)`, + expected: `{"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",4],["2009-11-10T23:00:15Z",10]]}]}]}`, + }, + { + name: "fill with none, i.e. clear out nulls", + query: `select mean(val) from "%DB%"."%RP%".fills where time >= '2009-11-10T23:00:00Z' and time < '2009-11-10T23:00:20Z' group by time(5s) fill(none)`, + expected: `{"results":[{"series":[{"name":"fills","columns":["time","mean"],"values":[["2009-11-10T23:00:00Z",4],["2009-11-10T23:00:05Z",4],["2009-11-10T23:00:15Z",10]]}]}]}`, + }, + { + name: "fill defaults to null", + query: `select mean(val) from "%DB%"."%RP%".fills where time >= '2009-11-10T23:00:00Z' and time < '2009-11-10T23:00:20Z' group by time(5s)`, + expected: `{"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]]}]}]}`, + }, + // Metadata display tests { diff --git a/influxql/INFLUXQL.md b/influxql/INFLUXQL.md index d305df7b3ae..a0b5b8746e3 100644 --- a/influxql/INFLUXQL.md +++ b/influxql/INFLUXQL.md @@ -576,7 +576,7 @@ select_stmt = fields from_clause [ into_clause ] [ where_clause ] ```sql -- select mean value from the cpu measurement where region = 'uswest' grouped by 10 minute intervals -SELECT mean(value) FROM cpu WHERE region = 'uswest' GROUP BY time(10m); +SELECT mean(value) FROM cpu WHERE region = 'uswest' GROUP BY time(10m) fill(0); ``` ## Clauses @@ -584,7 +584,7 @@ SELECT mean(value) FROM cpu WHERE region = 'uswest' GROUP BY time(10m); ``` from_clause = "FROM" measurements . -group_by_clause = "GROUP BY" dimensions . +group_by_clause = "GROUP BY" dimensions fill(