From e7cd5d45e00172cc4ab37eb38045ff1eb54263ef Mon Sep 17 00:00:00 2001 From: Scott Anderson <scott@influxdata.com> Date: Wed, 8 Apr 2020 09:55:11 -0600 Subject: [PATCH 1/3] WIP fill query guide --- content/v2.0/query-data/flux/fill.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 content/v2.0/query-data/flux/fill.md diff --git a/content/v2.0/query-data/flux/fill.md b/content/v2.0/query-data/flux/fill.md new file mode 100644 index 000000000..699883acd --- /dev/null +++ b/content/v2.0/query-data/flux/fill.md @@ -0,0 +1,26 @@ +--- +title: Fill gaps in data +seotitle: Fill gaps in data +list_title: Fill gaps +description: > + Use the [`fill()` function](/v2.0/reference/flux/stdlib/built-in/transformations/fill/) + to replace _null_ values in query results. +weight: 210 +menu: + v2_0: + parent: Query with Flux + name: Fill gaps +v2.0/tags: [query, fill] +list_code_example: | + ```js + data + |> fill(usePrevious: true) + ``` +--- + +Use the [`fill()` function](/v2.0/reference/flux/stdlib/built-in/transformations/fill/) +to replace _null_ values in query results. + +- Fill with a value +- Fill with previous +- Interpolate From c2d6537d22372ef3b1d97b13ed833a63dcf19d5f Mon Sep 17 00:00:00 2001 From: Scott Anderson <scott@influxdata.com> Date: Mon, 13 Apr 2020 09:41:40 -0600 Subject: [PATCH 2/3] fill query guide --- content/v2.0/query-data/flux/fill.md | 105 +++++++++++++++++++++++++-- 1 file changed, 98 insertions(+), 7 deletions(-) diff --git a/content/v2.0/query-data/flux/fill.md b/content/v2.0/query-data/flux/fill.md index 699883acd..4863f45f5 100644 --- a/content/v2.0/query-data/flux/fill.md +++ b/content/v2.0/query-data/flux/fill.md @@ -1,7 +1,7 @@ --- -title: Fill gaps in data -seotitle: Fill gaps in data -list_title: Fill gaps +title: Fill null values in data +seotitle: Fill null values in data +list_title: Fill null values description: > Use the [`fill()` function](/v2.0/reference/flux/stdlib/built-in/transformations/fill/) to replace _null_ values in query results. @@ -9,7 +9,7 @@ weight: 210 menu: v2_0: parent: Query with Flux - name: Fill gaps + name: Fill v2.0/tags: [query, fill] list_code_example: | ```js @@ -21,6 +21,97 @@ list_code_example: | Use the [`fill()` function](/v2.0/reference/flux/stdlib/built-in/transformations/fill/) to replace _null_ values in query results. -- Fill with a value -- Fill with previous -- Interpolate + +- [Use the previous non-null value](#fill-with-the-previous-value) to replace _null_ values +- [Specify a value](#fill-with-a-specified-value) to replace _null_ values + +<!-- --> +```js +data + |> fill(usePrevious: true) + +// OR + +data + |> fill(value: 0.0) +``` + +{{% note %}} +#### Fill empty windows of time +The `fill()` function **does not** fill empty windows of time. +It only replaces _null_ values in existing data. +Filling empty windows of time requires time interpolation +_(see [influxdata/flux#2428](https://github.com/influxdata/flux/issues/2428))_. +{{% /note %}} + +## Fill with the previous value +To fill _null_ values with the previous **non-null** value, set the `usePrevious` parameter to `true`. + +{{% note %}} +Values remain _null_ if there is no previous non-null value in the table. +{{% /note %}} + +```js +data + |> fill(usePrevious: true) +``` + +{{< flex >}} +{{% flex-content %}} +**Given the following input:** + +| _time | _value | +|:----- | ------:| +| 0001 | null | +| 0002 | 0.8 | +| 0003 | null | +| 0004 | null | +| 0005 | 1.4 | +{{% /flex-content %}} +{{% flex-content %}} +**`fill(usePrevious: true)` returns:** + +| _time | _value | +|:----- | ------:| +| 0001 | null | +| 0002 | 0.8 | +| 0003 | 0.8 | +| 0004 | 0.8 | +| 0005 | 1.4 | +{{% /flex-content %}} +{{< /flex >}} + +## Fill with a specified value +To fill _null_ values with a specified value, use the `value` parameter to specify the fill value. +_The fill value must match the [data type](/v2.0/reference/flux/language/types/#basic-types) +of the [column](/v2.0/reference/flux/stdlib/built-in/transformations/fill/#column)._ + +```js +data + |> fill(value: 0.0) +``` + +{{< flex >}} +{{% flex-content %}} +**Given the following input:** + +| _time | _value | +|:----- | ------:| +| 0001 | null | +| 0002 | 0.8 | +| 0003 | null | +| 0004 | null | +| 0005 | 1.4 | +{{% /flex-content %}} +{{% flex-content %}} +**`fill(value: 0.0)` returns:** + +| _time | _value | +|:----- | ------:| +| 0001 | 0.0 | +| 0002 | 0.8 | +| 0003 | 0.0 | +| 0004 | 0.0 | +| 0005 | 1.4 | +{{% /flex-content %}} +{{< /flex >}} From f71e85ee1ce4246111b921c81435df1669c043e7 Mon Sep 17 00:00:00 2001 From: Scott Anderson <scott@influxdata.com> Date: Thu, 23 Apr 2020 15:24:44 -0600 Subject: [PATCH 3/3] updated fill query guide to address PR feedback --- content/v2.0/query-data/flux/fill.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/content/v2.0/query-data/flux/fill.md b/content/v2.0/query-data/flux/fill.md index 4863f45f5..e23cf0706 100644 --- a/content/v2.0/query-data/flux/fill.md +++ b/content/v2.0/query-data/flux/fill.md @@ -1,10 +1,10 @@ --- title: Fill null values in data seotitle: Fill null values in data -list_title: Fill null values +list_title: Fill description: > Use the [`fill()` function](/v2.0/reference/flux/stdlib/built-in/transformations/fill/) - to replace _null_ values in query results. + to replace _null_ values. weight: 210 menu: v2_0: @@ -19,11 +19,10 @@ list_code_example: | --- Use the [`fill()` function](/v2.0/reference/flux/stdlib/built-in/transformations/fill/) -to replace _null_ values in query results. +to replace _null_ values with: - -- [Use the previous non-null value](#fill-with-the-previous-value) to replace _null_ values -- [Specify a value](#fill-with-a-specified-value) to replace _null_ values +- [the previous non-null value](#fill-with-the-previous-value) +- [a specified value](#fill-with-a-specified-value) <!-- --> ```js