diff --git a/content/v2.0/reference/flux/functions/built-in/misc/sleep.md b/content/v2.0/reference/flux/functions/built-in/misc/sleep.md
new file mode 100644
index 000000000..7e6221048
--- /dev/null
+++ b/content/v2.0/reference/flux/functions/built-in/misc/sleep.md
@@ -0,0 +1,53 @@
+---
+title: sleep() function
+description: The `sleep()` function delays execution by a specified duration.
+menu:
+ v2_0_ref:
+ name: sleep
+ parent: built-in-misc
+weight: 401
+---
+
+The `sleep()` function delays execution by a specified duration.
+
+_**Function type:** Miscellaneous_
+
+```js
+sleep(
+ v: x,
+ duration: 10s
+)
+```
+
+## Parameters
+
+### v
+Defines input tables.
+`sleep()` accepts piped-forward data and passes it on unmodified after the
+specified [duration](#duration).
+If data is not piped-forward into `sleep()`, set `v` to specify a stream object.
+The examples [below](#examples) illustrate how.
+
+_**Data type:** Object_
+
+### duration
+The length of time to delay execution.
+
+_**Data type:** Duration_
+
+## Examples
+
+### Delay execution in a chained query
+```js
+from(bucket: "example-bucket")
+ |> range(start: -1h)
+ |> sleep(duration: 10s)
+```
+
+### Delay execution using a stream variable
+```js
+x = from(bucket: "example-bucket")
+ |> range(start: -1h)
+
+sleep(v: x, duration: 10s)
+```
diff --git a/content/v2.0/reference/flux/functions/built-in/transformations/aggregates/mode.md b/content/v2.0/reference/flux/functions/built-in/transformations/aggregates/mode.md
index abbbfc86a..ef3916c57 100644
--- a/content/v2.0/reference/flux/functions/built-in/transformations/aggregates/mode.md
+++ b/content/v2.0/reference/flux/functions/built-in/transformations/aggregates/mode.md
@@ -8,7 +8,6 @@ menu:
name: mode
parent: built-in-aggregates
weight: 501
-draft: true
---
The `mode()` function computes the mode or value that occurs most often in a
@@ -20,6 +19,18 @@ _**Function type:** Aggregate_
mode(column: "_value")
```
+Multiple modes are returned in a sorted table.
+If there is no mode, `mode()` returns `null`.
+
+##### Supported data types
+
+- String
+- Float
+- Integer
+- UInteger
+- Boolean
+- Time
+
## Parameters
### column
@@ -30,7 +41,7 @@ _**Data type:** String_
## Examples
-###### Mode as an aggregate
+###### Return the mode of windowed data
```js
from(bucket: "example-bucket")
|> filter(fn: (r) =>
diff --git a/content/v2.0/reference/flux/functions/built-in/transformations/aggregates/movingaverage.md b/content/v2.0/reference/flux/functions/built-in/transformations/aggregates/movingaverage.md
index 0ecb1b0e8..60c08af83 100644
--- a/content/v2.0/reference/flux/functions/built-in/transformations/aggregates/movingaverage.md
+++ b/content/v2.0/reference/flux/functions/built-in/transformations/aggregates/movingaverage.md
@@ -1,61 +1,57 @@
---
title: movingAverage() function
description: >
- The `movingAverage()` function calculates the mean of values in a defined time
- range at a specified frequency.
+ The `movingAverage()` function calculates the mean of values grouped into `n` number of points.
menu:
v2_0_ref:
name: movingAverage
parent: built-in-aggregates
weight: 501
+related:
+ - /v2.0/reference/flux/functions/built-in/transformations/aggregates/timedmovingaverage/
+ - https://docs.influxdata.com/influxdb/latest/query_language/functions/#moving-average, InfluxQL MOVING_AVERAGE()
---
-The `movingAverage()` function calculates the mean of values in a defined time
-range at a specified frequency.
+The `movingAverage()` function calculates the mean of values grouped into `n` number of points.
_**Function type:** Aggregate_
```js
movingAverage(
- every: 1d,
- period: 5d,
- column="_value"
+ n: 5,
+ columns: ["_value"]
)
```
+##### Moving average rules:
+- The average over a period populated by `n` values is equal to their algebraic mean.
+- The average over a period populated by only `null` values is `null`.
+- Moving averages skip `null` values.
+- If `n` is less than the number of records in a table, `movingAverage` returns
+ the average of the available values.
+
## Parameters
-### every
-The frequency of time windows.
+### n
+The number of points to average.
-_**Data type:** Duration_
+_**Data type:** Integer_
-### period
-The length of each averaged time window.
-_A negative duration indicates start and stop boundaries are reversed._
+### columns
+Columns to operate on. _Defaults to `["_value"]`_.
-_**Data type:** Duration_
-
-### column
-The column used to compute the moving average.
-Defaults to `"_value"`.
-
-_**Data type:** String_
+_**Data type:** Array of Strings_
## Examples
-###### Calculate a five year moving average every year
+#### Calculate a five point moving average
```js
from(bucket: "example-bucket"):
- |> range(start: -7y)
- |> filter(fn: (r) =>
- r._measurement == "financial" and
- r._field == "closing_price"
- )
- |> movingAverage(every: 1y, period: 5y)
+ |> range(start: -12h)
+ |> movingAverage(n: 5)
```
-## Function definition
+#### Calculate a ten point moving average
```js
movingAverage = (every, period, column="_value", tables=<-) =>
tables
@@ -65,7 +61,26 @@ movingAverage = (every, period, column="_value", tables=<-) =>
|> window(every: inf)
```
-
+#### Table transformation with a two point moving average
-##### Related InfluxQL functions and statements:
-[MOVING_AVERAGE()](https://docs.influxdata.com/influxdb/latest/query_language/functions/#moving-average)
+###### Input table:
+| _time | A | B | C | D | tag |
+|:-----:|:----:|:----:|:----:|:----:|:---:|
+| 0001 | null | 1 | 2 | null | tv |
+| 0002 | 6 | 2 | null | null | tv |
+| 0003 | 4 | null | 4 | 4 | tv |
+
+###### Query:
+```js
+// ...
+ |> movingAverage(
+ n: 2,
+ columns: ["A", "B", "C", "D"]
+ )
+```
+
+###### Output table:
+| _time | A | B | C | D | tag |
+|:-----:|:----:|:----:|:----:|:----:|:---:|
+| 0002 | 6 | 1.5 | 2 | null | tv |
+| 0003 | 5 | 2 | 4 | 4 | tv |
diff --git a/content/v2.0/reference/flux/functions/built-in/transformations/aggregates/timedmovingaverage.md b/content/v2.0/reference/flux/functions/built-in/transformations/aggregates/timedmovingaverage.md
new file mode 100644
index 000000000..acaedcbe8
--- /dev/null
+++ b/content/v2.0/reference/flux/functions/built-in/transformations/aggregates/timedmovingaverage.md
@@ -0,0 +1,80 @@
+---
+title: timedMovingAverage() function
+description: >
+ The `timedMovingAverage()` function calculates the mean of values in a defined time
+ range at a specified frequency.
+menu:
+ v2_0_ref:
+ name: timedMovingAverage
+ parent: built-in-aggregates
+weight: 501
+related:
+ - /v2.0/reference/flux/functions/built-in/transformations/aggregates/movingaverage/
+ - https://docs.influxdata.com/influxdb/latest/query_language/functions/#moving-average, InfluxQL MOVING_AVERAGE()
+---
+
+The `timedMovingAverage()` function calculates the mean of values in a defined time
+range at a specified frequency.
+
+_**Function type:** Aggregate_
+
+```js
+timedMovingAverage(
+ every: 1d,
+ period: 5d,
+ column="_value"
+)
+```
+
+## Parameters
+
+### every
+The frequency of time windows.
+
+_**Data type:** Duration_
+
+### period
+The length of each averaged time window.
+_A negative duration indicates start and stop boundaries are reversed._
+
+_**Data type:** Duration_
+
+### column
+The column used to compute the moving average.
+Defaults to `"_value"`.
+
+_**Data type:** String_
+
+## Examples
+
+###### Calculate a seven day moving average every day
+```js
+from(bucket: "example-bucket"):
+ |> range(start: -7y)
+ |> filter(fn: (r) =>
+ r._measurement == "financial" and
+ r._field == "closing_price"
+ )
+ |> timedMovingAverage(every: 1y, period: 5y)
+```
+
+###### Calculate a five year moving average every year
+```js
+from(bucket: "example-bucket"):
+ |> range(start: -50d)
+ |> filter(fn: (r) =>
+ r._measurement == "financial" and
+ r._field == "closing_price"
+ )
+ |> timedMovingAverage(every: 1d, period: 7d)
+```
+
+## Function definition
+```js
+timedMovingAverage = (every, period, column="_value", tables=<-) =>
+ tables
+ |> window(every: every, period: period)
+ |> mean(column:column)
+ |> duplicate(column: "_stop", as: "_time")
+ |> window(every: inf)
+```
diff --git a/content/v2.0/reference/flux/functions/built-in/transformations/elapsed.md b/content/v2.0/reference/flux/functions/built-in/transformations/elapsed.md
new file mode 100644
index 000000000..0c410b1f0
--- /dev/null
+++ b/content/v2.0/reference/flux/functions/built-in/transformations/elapsed.md
@@ -0,0 +1,54 @@
+---
+title: elapsed() function
+description: The `elapsed()` function returns the time between subsequent records.
+menu:
+ v2_0_ref:
+ name: elapsed
+ parent: built-in-transformations
+weight: 401
+---
+
+The `elapsed()` function returns the time between subsequent records.
+Given an input table, `elapsed()` returns the same table without the first record
+(as elapsed time is not defined) and an additional column containing the elapsed time.
+
+_**Function type:** Transformation_
+
+```js
+elapsed(
+ unit: 1s,
+ timeColumn: "_time",
+ columnName: "elapsed"
+)
+```
+
+_`elapsed()` returns an errors if the `timeColumn` is not present in the input table._
+
+## Parameters
+
+### unit
+The unit time to returned.
+_Defaults to `1s`._
+
+_**Data type:** Duration_
+
+### timeColumn
+The column to use to compute the elapsed time.
+_Defaults to `"_time"`._
+
+_**Data type:** String_
+
+### columnName
+The column to store elapsed times.
+_Defaults to `"elapsed"`._
+
+_**Data type:** String_
+
+## Examples
+
+##### Calculate the time between points in seconds
+```js
+from(bucket: "example-bucket")
+ |> range(start: -5m)
+ |> elapsed(unit: 1s)
+```
diff --git a/content/v2.0/reference/release-notes/flux.md b/content/v2.0/reference/release-notes/flux.md
index c4bf927c9..2153c4f87 100644
--- a/content/v2.0/reference/release-notes/flux.md
+++ b/content/v2.0/reference/release-notes/flux.md
@@ -11,11 +11,52 @@ aliases:
---
{{% note %}}
-_The latest release of InfluxDB v2.0 alpha includes **Flux v0.35.1**.
+_The latest release of InfluxDB v2.0 alpha includes **Flux v0.36.1**.
Though newer versions of Flux may be available, they will not be included with
InfluxDB until the next InfluxDB v2.0 release._
{{% /note %}}
+## v0.36.2 [2019-07-12]
+
+### Bug fixes
+- Add helper methods for comparing entire result sets.
+- Map will not panic when a record is `null`.
+
+---
+
+## v0.36.1 [2019-07-10]
+
+### Bug fixes
+- Add `range` call to some end-to-end tests.
+- Fix implementation of `strings.replaceAll`.
+
+---
+
+## v0.36.0 [2019-07-09]
+
+### Features
+- Updated `movingAverage()` and added `timedMovingAverage`.
+- `elapsed()` function.
+- `mode()` function.
+- `sleep()` function.
+- Modify error usage in places to use the new enriched errors.
+- Enriched error interface.
+- End-to-end tests that show how to mimic pandas functionality.
+- End-to-end tests for string functions.
+
+### Bug fixes
+- Fix `difference()` so that it returns an error instead of panicking when given a `_time` column.
+- Added end-to-end tests for type conversion functions.
+- Make `map()` error if return type is not an object.
+- Fixed miscounted allocations in the `ColListTableBuilder`.
+- Support formatting `with`.
+
+### Breaking changes
+- Updated `movingAverage()` to `timedMovingAverage` and added new
+ `movingAverage()` implementation.
+
+---
+
## v0.35.1 [2019-07-03]
### Bug fixes
diff --git a/layouts/partials/article/related.html b/layouts/partials/article/related.html
index 7bbe046e0..7817ad286 100644
--- a/layouts/partials/article/related.html
+++ b/layouts/partials/article/related.html
@@ -4,7 +4,7 @@
{{ range .Params.related }}
{{ if in . "http" }}
- {{ $link := replaceRE `\,\s(...)*$` "" . }}
+ {{ $link := replaceRE `\,\s(.*)$` "" . }}
{{ $title := replaceRE `^(\S*\,\s)` "" . }}
- {{ $title }}
{{ else }}