resolved merge conflicts with flux-0.18
commit
f8f289f03e
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
title: Built-in Flux functions
|
||||
title: Flux built-in functions
|
||||
description: >
|
||||
Built-in functions provide a necessary foundation for working with data using Flux.
|
||||
They do not require an import statement and are usable without any extra setup.
|
||||
|
|
|
|||
|
|
@ -18,9 +18,13 @@ The generator is then used to produce the set of intervals.
|
|||
The set of intervals includes all intervals that intersect with the initial range of time.
|
||||
|
||||
{{% note %}}
|
||||
The `intervals()` function is designed to be used with the intervals parameter of the [`window()` function](/v2.0/reference/flux/functions/transformations/window).
|
||||
The `intervals()` function is designed to be used with the intervals parameter
|
||||
of the [`window()` function](/v2.0/reference/flux/functions/transformations/window).
|
||||
{{% /note %}}
|
||||
|
||||
By default the end boundary of an interval will align with the Unix epoch (zero time)
|
||||
modified by the offset of the `location` option.
|
||||
|
||||
_**Function type:** Miscellaneous_
|
||||
_**Output data type:** Object_
|
||||
|
||||
|
|
@ -46,9 +50,9 @@ Defaults to the value of the `every` duration.
|
|||
_**Data type:** Duration_
|
||||
|
||||
### offset
|
||||
The offset duration relative to the location offset.
|
||||
The duration by which to shift the window boundaries.
|
||||
It can be negative, indicating that the offset goes backwards in time.
|
||||
Defaults to `0h`.
|
||||
Defaults to `0`, which will align window end boundaries with the `every` duration.
|
||||
|
||||
_**Data type:** Duration_
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +0,0 @@
|
|||
---
|
||||
title: Flux testing functions
|
||||
description: Flux testing functions test piped-forward data in specific ways and return errors if the tests fail.
|
||||
aliases:
|
||||
- /v2.0/reference/flux/functions/tests
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: Tests
|
||||
parent: Built-in
|
||||
identifier: built-in-tests
|
||||
weight: 305
|
||||
---
|
||||
|
||||
Flux testing functions test piped-forward data in specific ways and return errors if the tests fail.
|
||||
The following testing functions are available:
|
||||
|
||||
{{< children type="functions" >}}
|
||||
|
|
@ -16,6 +16,9 @@ Those columns are added to the group key of the output tables.
|
|||
|
||||
A single input record will be placed into zero or more output tables, depending on the specific windowing function.
|
||||
|
||||
By default the start boundary of a window will align with the Unix epoch (zero time)
|
||||
modified by the offset of the `location` option.
|
||||
|
||||
_**Function type:** Transformation_
|
||||
_**Output data type:** Object_
|
||||
|
||||
|
|
@ -23,10 +26,11 @@ _**Output data type:** Object_
|
|||
window(
|
||||
every: 5m,
|
||||
period: 5m,
|
||||
start: 12h,
|
||||
offset: 12h,
|
||||
timeColumn: "_time",
|
||||
startColumn: "_start",
|
||||
stopColumn: "_stop"
|
||||
stopColumn: "_stop",
|
||||
createEmpty: false
|
||||
)
|
||||
|
||||
// OR
|
||||
|
|
@ -35,7 +39,8 @@ window(
|
|||
intervals: intervals(every: 5m, period: 5m, offset: 12h),
|
||||
timeColumn: "_time",
|
||||
startColumn: "_start",
|
||||
stopColumn: "_stop"
|
||||
stopColumn: "_stop",
|
||||
createEmpty: false
|
||||
)
|
||||
```
|
||||
|
||||
|
|
@ -59,10 +64,10 @@ Defaults to `every` value.
|
|||
|
||||
_**Data type:** Duration_
|
||||
|
||||
### start
|
||||
The start window time relative to the [`location`](/v2.0/reference/flux/language/options/#location) offset.
|
||||
It can be negative, indicating that the start goes backwards in time.
|
||||
The default aligns the window boundaries with `now`.
|
||||
### offset
|
||||
Offset is the duration by which to shift the window boundaries.
|
||||
It can be negative, indicating that the offset goes backwards in time.
|
||||
Defaults to 0, which will align window end boundaries with the `every` duration.
|
||||
|
||||
_**Data type:** Duration_
|
||||
|
||||
|
|
@ -98,6 +103,10 @@ Defaults to `"_stop"`.
|
|||
|
||||
_**Data type:** String_
|
||||
|
||||
### createEmpty
|
||||
Specifies whether empty tables should be created.
|
||||
Defaults to `false`.
|
||||
|
||||
## Examples
|
||||
|
||||
#### Window data into 10 minute intervals
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
title: InfluxDB v1 Flux functions
|
||||
title: Flux InfluxDB v1 functions
|
||||
description: >
|
||||
InfluxDB v1 Flux functions provide tools for managing data from an InfluxDB v1.x
|
||||
database or structured using the InfluxDB v1 data structure.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
title: String Flux functions
|
||||
title: Flux string functions
|
||||
description: >
|
||||
String functions provide tools for manipulating strings in Flux.
|
||||
To use them, import the "strings" package:
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
---
|
||||
title: Flux Testing functions
|
||||
description: >
|
||||
Flux testing functions test piped-forward data in specific ways and return errors if the tests fail.
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: Testing
|
||||
parent: Flux functions
|
||||
weight: 204
|
||||
---
|
||||
|
||||
Flux testing functions test piped-forward data in specific ways and return errors if the tests fail.
|
||||
To use them, import the `testing` package:
|
||||
|
||||
```js
|
||||
import "testing"
|
||||
```
|
||||
|
||||
{{< children type="functions" show="pages" >}}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
---
|
||||
title: testing.assertEmpty() function
|
||||
description: The testing.assertEmpty() function tests if an input stream is empty.
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: testing.assertEmpty
|
||||
parent: Testing
|
||||
weight: 301
|
||||
---
|
||||
|
||||
The `testing.assertEmpty()` function tests if an input stream is empty.
|
||||
If not empty, the function outputs an error.
|
||||
|
||||
_**Function type:** Test_
|
||||
|
||||
```js
|
||||
import "testing"
|
||||
|
||||
testing.assertEmpty()
|
||||
```
|
||||
|
||||
_The `testing.assertEmpty()` function can be used to perform in-line tests in a query._
|
||||
|
||||
## Examples
|
||||
|
||||
#### Check if there is a difference between streams
|
||||
This example uses the [`diff()` function](/flux/v0.x/functions/tests/diff)
|
||||
which outputs the diff for the two streams.
|
||||
The `.testing.assertEmpty()` function checks to see if the diff is empty.
|
||||
|
||||
```js
|
||||
import "testing"
|
||||
|
||||
got = from(bucket: "telegraf/autogen")
|
||||
|> range(start: -15m)
|
||||
want = from(bucket: "backup_telegraf/autogen")
|
||||
|> range(start: -15m)
|
||||
got
|
||||
|> diff(want: want)
|
||||
|> testing.assertEmpty()
|
||||
```
|
||||
|
|
@ -1,45 +1,45 @@
|
|||
---
|
||||
title: assertEquals() function
|
||||
description: The assertEquals() function tests whether two streams have identical data.
|
||||
title: testing.assertEquals() function
|
||||
description: The testing.assertEquals() function tests whether two streams have identical data.
|
||||
aliases:
|
||||
- /v2.0/reference/flux/functions/tests/assertequals
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: assertEquals
|
||||
parent: built-in-tests
|
||||
weight: 401
|
||||
name: testing.assertEquals
|
||||
parent: Testing
|
||||
weight: 301
|
||||
---
|
||||
|
||||
The `assertEquals()` function tests whether two streams have identical data.
|
||||
The `testing.assertEquals()` function tests whether two streams have identical data.
|
||||
If equal, the function outputs the tested data stream unchanged.
|
||||
If unequal, the function outputs an error.
|
||||
|
||||
_**Function type:** Test_
|
||||
|
||||
```js
|
||||
assertEquals(
|
||||
import "testing"
|
||||
|
||||
testing.assertEquals(
|
||||
name: "streamEquality",
|
||||
got: got,
|
||||
want: want
|
||||
)
|
||||
```
|
||||
|
||||
_The `assertEquals()` function can be used to perform in-line tests in a query._
|
||||
_The `testing.assertEquals()` function can be used to perform in-line tests in a query._
|
||||
|
||||
## Parameters
|
||||
|
||||
## name
|
||||
### name
|
||||
Unique name given to the assertion.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
## got
|
||||
### got
|
||||
The stream containing data to test.
|
||||
Defaults to data piped-forward from another function (`<-`).
|
||||
Defaults to piped-forward data (`<-`).
|
||||
|
||||
_**Data type:** Object_
|
||||
|
||||
## want
|
||||
### want
|
||||
The stream that contains the expected data to test against.
|
||||
|
||||
_**Data type:** Object_
|
||||
|
|
@ -49,21 +49,25 @@ _**Data type:** Object_
|
|||
|
||||
##### Assert of separate streams
|
||||
```js
|
||||
import "testing"
|
||||
|
||||
want = from(bucket: "backup-telegraf/autogen")
|
||||
|> range(start: -5m)
|
||||
|
||||
got = from(bucket: "telegraf/autogen")
|
||||
|> range(start: -5m)
|
||||
|
||||
assertEquals(got: got, want: want)
|
||||
testing.assertEquals(got: got, want: want)
|
||||
```
|
||||
|
||||
##### Inline assertion
|
||||
```js
|
||||
import "testing"
|
||||
|
||||
want = from(bucket: "backup-telegraf/autogen")
|
||||
|> range(start: -5m)
|
||||
|
||||
from(bucket: "telegraf/autogen")
|
||||
|> range(start: -5m)
|
||||
|> assertEquals(want: want)
|
||||
|> testing.assertEquals(want: want)
|
||||
```
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
---
|
||||
title: testing.diff() function
|
||||
description: The testing.diff() function produces a diff between two streams.
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: testing.diff
|
||||
parent: Testing
|
||||
weight: 301
|
||||
---
|
||||
|
||||
The `testing.diff()` function produces a diff between two streams.
|
||||
|
||||
_**Function type:** Test_
|
||||
|
||||
```js
|
||||
import "testing"
|
||||
|
||||
testing.diff(got: stream2, want: stream1)
|
||||
```
|
||||
|
||||
It matches tables from each stream with the same group keys.
|
||||
For each matched table, it produces a diff.
|
||||
Any added or removed rows are added to the table as a row.
|
||||
An additional string column with the name `diff` is created and contains a `-` if the
|
||||
row was present in the `got` table and not in the `want` table or `+` if the opposite is true.
|
||||
|
||||
The diff function is guaranteed to emit at least one row if the tables are
|
||||
different and no rows if the tables are the same. _The exact diff produced may change._
|
||||
|
||||
_The `testing.diff()` function can be used to perform in-line diffs in a query._
|
||||
|
||||
## Parameters
|
||||
|
||||
### got
|
||||
The stream containing data to test.
|
||||
_Defaults to piped-forward data (`<-`)._
|
||||
|
||||
_**Data type:** Object_
|
||||
|
||||
### want
|
||||
The stream that contains the expected data to test against.
|
||||
|
||||
_**Data type:** Object_
|
||||
|
||||
## Examples
|
||||
|
||||
##### Diff separate streams
|
||||
```js
|
||||
import "testing"
|
||||
|
||||
want = from(bucket: "backup-telegraf/autogen")
|
||||
|> range(start: -5m)
|
||||
got = from(bucket: "telegraf/autogen")
|
||||
|> range(start: -5m)
|
||||
testing.diff(got: got, want: want)
|
||||
```
|
||||
|
||||
##### Inline diff
|
||||
```js
|
||||
import "testing"
|
||||
|
||||
want = from(bucket: "backup-telegraf/autogen") |> range(start: -5m)
|
||||
from(bucket: "telegraf/autogen")
|
||||
|> range(start: -5m)
|
||||
|> testing.diff(want: want)
|
||||
```
|
||||
Loading…
Reference in New Issue