Merge branch 'flux-0.36' into flux-0.37
commit
aa3857ab2d
|
@ -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)
|
||||
```
|
|
@ -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) =>
|
||||
|
|
|
@ -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)
|
||||
```
|
||||
|
||||
<hr style="margin-top:4rem"/>
|
||||
#### 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 |
|
||||
|
|
|
@ -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)
|
||||
```
|
|
@ -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)
|
||||
```
|
|
@ -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
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<ul>
|
||||
{{ range .Params.related }}
|
||||
{{ if in . "http" }}
|
||||
{{ $link := replaceRE `\,\s(...)*$` "" . }}
|
||||
{{ $link := replaceRE `\,\s(.*)$` "" . }}
|
||||
{{ $title := replaceRE `^(\S*\,\s)` "" . }}
|
||||
<li><a href="{{ $link }}" target="_blank">{{ $title }}</a></li>
|
||||
{{ else }}
|
||||
|
|
Loading…
Reference in New Issue