Merge pull request #52 from influxdata/flux-0.18

Flux 0.18
pull/53/head
Scott Anderson 2019-02-08 09:15:57 -07:00 committed by GitHub
commit d0b92fc1f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
100 changed files with 1089 additions and 243 deletions

View File

@ -9,7 +9,6 @@ weight: 101
---
Flux's functional syntax allows you to retrieve, transform, process, and output data easily.
There is a large library of built-in functions, but you can also create your own
custom functions to perform operations that suit your needs.
There is a large library of built-in and importable functions:
{{< children >}}

View File

@ -0,0 +1,18 @@
---
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.
menu:
v2_0_ref:
name: Built-in
parent: Flux functions
weight: 201
---
Built-in functions provide a necessary foundation for working with data using Flux.
Because these functions are "built-in," they do not require an `import` statement and are usable without any extra setup.
Built-in functions are grouped into the following categories:
{{< children >}}

View File

@ -1,11 +1,14 @@
---
title: Flux input functions
description: Flux input functions define sources of data or or display information about data sources.
aliases:
- /v2.0/reference/flux/functions/inputs
menu:
v2_0_ref:
parent: Flux functions
parent: Built-in
name: Inputs
weight: 201
identifier: built-in-inputs
weight: 301
---
Flux input functions define sources of data or display information about data sources.

View File

@ -1,11 +1,13 @@
---
title: buckets() function
description: The buckets() function returns a list of buckets in the organization.
aliases:
- /v2.0/reference/flux/functions/inputs/buckets
menu:
v2_0_ref:
name: buckets
parent: Inputs
weight: 301
parent: built-in-inputs
weight: 401
---
The `buckets()` function returns a list of buckets in the organization.

View File

@ -1,11 +1,13 @@
---
title: from() function
description: The from() function retrieves data from an InfluxDB data source.
aliases:
- /v2.0/reference/flux/functions/inputs/from
menu:
v2_0_ref:
name: from
parent: Inputs
weight: 301
parent: built-in-inputs
weight: 401
---
The `from()` function retrieves data from an InfluxDB data source.

View File

@ -1,11 +1,13 @@
---
title: fromCSV() function
description: The fromCSV() function retrieves data from a CSV data source.
aliases:
- /v2.0/reference/flux/functions/inputs/fromcsv
menu:
v2_0_ref:
name: fromCSV
parent: Inputs
weight: 301
parent: built-in-inputs
weight: 401
---
The `fromCSV()` function retrieves data from a comma-separated value (CSV) data source.

View File

@ -1,11 +1,14 @@
---
title: Flux miscellaneous functions
description: Flux provides miscellaneous functions that serve purposes other than retrieving, transforming, or outputting data.
aliases:
- /v2.0/reference/flux/functions/misc
menu:
v2_0_ref:
parent: Flux functions
parent: Built-in
name: Miscellaneous
weight: 205
identifier: built-in-misc
weight: 305
---
Flux functions primarily retrieve, shape and transform, then output data, however

View File

@ -1,11 +1,13 @@
---
title: intervals() function
description: The intervals() function generates a set of time intervals over a range of time.
aliases:
- /v2.0/reference/flux/functions/misc/intervals
menu:
v2_0_ref:
name: intervals
parent: Miscellaneous
weight: 301
parent: built-in-misc
weight: 401
---
The `intervals()` function generates a set of time intervals over a range of time.
@ -16,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_
@ -44,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_

View File

@ -1,11 +1,13 @@
---
title: linearBins() function
description: The linearBins() function generates a list of linearly separated floats.
aliases:
- /v2.0/reference/flux/functions/misc/linearbins
menu:
v2_0_ref:
name: linearBins
parent: Miscellaneous
weight: 301
parent: built-in-misc
weight: 401
---
The `linearBins()` function generates a list of linearly separated floats.

View File

@ -1,11 +1,13 @@
---
title: logarithmicBins() function
description: The logarithmicBins() function generates a list of exponentially separated floats.
aliases:
- /v2.0/reference/flux/functions/misc/logarithmicbins
menu:
v2_0_ref:
name: logarithmicBins
parent: Miscellaneous
weight: 301
parent: built-in-misc
weight: 401
---
The `logarithmicBins()` function generates a list of exponentially separated floats.

View File

@ -1,11 +1,13 @@
---
title: systemTime() function
description: The systemTime() function returns the current system time.
aliases:
- /v2.0/reference/flux/functions/misc/systemtime
menu:
v2_0_ref:
name: systemTime
parent: Miscellaneous
weight: 301
parent: built-in-misc
weight: 401
---
The `systemTime()` function returns the current system time.

View File

@ -1,11 +1,14 @@
---
title: Flux output functions
description: Flux output functions yield results or send data to a specified output destination.
aliases:
- /v2.0/reference/flux/functions/outputs
menu:
v2_0_ref:
parent: Flux functions
parent: Built-in
name: Outputs
weight: 202
identifier: built-in-outputs
weight: 302
---
Flux output functions yield results or send data to a specified output destination.

View File

@ -1,11 +1,13 @@
---
title: to() function
description: The to() function writes data to an InfluxDB v2.0 bucket.
aliases:
- /v2.0/reference/flux/functions/outputs/to
menu:
v2_0_ref:
name: to
parent: Outputs
weight: 301
parent: built-in-outputs
weight: 401
---
The `to()` function writes data to an **InfluxDB v2.0** bucket.

View File

@ -1,11 +1,13 @@
---
title: yield() function
description: The yield() function indicates the input tables received should be delivered as a result of the query.
aliases:
- /v2.0/reference/flux/functions/outputs/yield
menu:
v2_0_ref:
name: yield
parent: Outputs
weight: 301
parent: built-in-outputs
weight: 401
---
The `yield()` function indicates the input tables received should be delivered as a result of the query.

View File

@ -1,11 +1,14 @@
---
title: Flux transformation functions
description: Flux transformation functions transform and shape your data in specific ways.
aliases:
- /v2.0/reference/flux/functions/transformations
menu:
v2_0_ref:
parent: Flux functions
parent: Built-in
name: Transformations
weight: 203
identifier: built-in-transformations
weight: 303
---
Flux transformation functions transform or shape your data in specific ways.

View File

@ -1,11 +1,14 @@
---
title: Flux aggregate functions
description: Flux aggregate functions take values from an input table and aggregate them in some way.
aliases:
- /v2.0/reference/flux/functions/transformations/aggregates
menu:
v2_0_ref:
parent: Transformations
parent: built-in-transformations
name: Aggregates
weight: 301
identifier: built-in-aggregates
weight: 401
---
Flux aggregate functions take values from an input table and aggregate them in some way.

View File

@ -1,11 +1,13 @@
---
title: aggregateWindow() function
description: The aggregateWindow() function applies an aggregate function to fixed windows of time.
aliases:
- /v2.0/reference/flux/functions/transformations/aggregates/aggregatewindow
menu:
v2_0_ref:
name: aggregateWindow
parent: Aggregates
weight: 401
parent: built-in-aggregates
weight: 501
---
The `aggregateWindow()` function applies an aggregate function to fixed windows of time.

View File

@ -1,11 +1,13 @@
---
title: count() function
description: The count() function outputs the number of non-null records in each aggregated column.
aliases:
- /v2.0/reference/flux/functions/transformations/aggregates/count
menu:
v2_0_ref:
name: count
parent: Aggregates
weight: 401
parent: built-in-aggregates
weight: 501
---
The `count()` function outputs the number of records in each aggregated column.

View File

@ -1,11 +1,13 @@
---
title: cov() function
description: The cov() function computes the covariance between two streams by first joining the streams, then performing the covariance operation.
aliases:
- /v2.0/reference/flux/functions/transformations/aggregates/cov
menu:
v2_0_ref:
name: cov
parent: Aggregates
weight: 401
parent: built-in-aggregates
weight: 501
---
The `cov()` function computes the covariance between two streams by first joining the streams,

View File

@ -1,11 +1,13 @@
---
title: covariance() function
description: The covariance() function computes the covariance between two columns.
aliases:
- /v2.0/reference/flux/functions/transformations/aggregates/covariance
menu:
v2_0_ref:
name: covariance
parent: Aggregates
weight: 401
parent: built-in-aggregates
weight: 501
---
The `covariance()` function computes the covariance between two columns.

View File

@ -1,11 +1,13 @@
---
title: derivative() function
description: The derivative() function computes the rate of change per unit of time between subsequent non-null records.
aliases:
- /v2.0/reference/flux/functions/transformations/aggregates/derivative
menu:
v2_0_ref:
name: derivative
parent: Aggregates
weight: 401
parent: built-in-aggregates
weight: 501
---
The `derivative()` function computes the rate of change per [`unit`](#unit) of time between subsequent non-null records.

View File

@ -1,11 +1,13 @@
---
title: difference() function
description: The difference() function computes the difference between subsequent non-null records.
aliases:
- /v2.0/reference/flux/functions/transformations/aggregates/difference
menu:
v2_0_ref:
name: difference
parent: Aggregates
weight: 401
parent: built-in-aggregates
weight: 501
---
The `difference()` function computes the difference between subsequent records.

View File

@ -1,11 +1,13 @@
---
title: histogramQuantile() function
description: The `histogramQuantile()` function approximates a quantile given a histogram that approximates the cumulative distribution of the dataset.
aliases:
- /v2.0/reference/flux/functions/transformations/aggregates/histogramquantile
menu:
v2_0_ref:
name: histogramQuantile
parent: Aggregates
weight: 401
parent: built-in-aggregates
weight: 501
---
The `histogramQuantile()` function approximates a quantile given a histogram that

View File

@ -1,11 +1,13 @@
---
title: increase() function
description: The increase() function calculates the total non-negative difference between values in a table.
aliases:
- /v2.0/reference/flux/functions/transformations/aggregates/increase
menu:
v2_0_ref:
name: increase
parent: Aggregates
weight: 401
parent: built-in-aggregates
weight: 501
---
The `increase()` function calculates the total non-negative difference between values in a table.

View File

@ -1,11 +1,13 @@
---
title: integral() function
description: The integral() function computes the area under the curve per unit of time of subsequent non-null records.
aliases:
- /v2.0/reference/flux/functions/transformations/aggregates/integral
menu:
v2_0_ref:
name: integral
parent: Aggregates
weight: 401
parent: built-in-aggregates
weight: 501
---
The `integral()` function computes the area under the curve per [`unit`](#unit) of time of subsequent non-null records.

View File

@ -1,11 +1,13 @@
---
title: mean() function
description: The mean() function computes the mean or average of non-null records in the input table.
aliases:
- /v2.0/reference/flux/functions/transformations/aggregates/mean
menu:
v2_0_ref:
name: mean
parent: Aggregates
weight: 401
parent: built-in-aggregates
weight: 501
---
The `mean()` function computes the mean or average of non-null records in the input table.

View File

@ -1,11 +1,13 @@
---
title: median() function
description: The `median()` function returns the median `_value` of an input table or all non-null records in the input table with values that fall within the 50th percentile.
description: The `median()` function returns the median `_value` of an input table or all non-null records in the input table with values that fall within the 50th percentile
aliases:
- /v2.0/reference/flux/functions/transformations/aggregates/median
menu:
v2_0_ref:
name: median
parent: Aggregates
weight: 401
parent: built-in-aggregates
weight: 501
---
The `median()` function is a special application of the [`percentile()` function](/v2.0/reference/flux/functions/transformations/aggregates/percentile)

View File

@ -1,11 +1,13 @@
---
title: pearsonr() function
description: The pearsonr() function computes the Pearson R correlation coefficient between two streams by first joining the streams, then performing the covariance operation normalized to compute R.
aliases:
- /v2.0/reference/flux/functions/transformations/aggregates/pearsonr
menu:
v2_0_ref:
name: pearsonr
parent: Aggregates
weight: 401
parent: built-in-aggregates
weight: 501
---
The `pearsonr()` function computes the Pearson R correlation coefficient between two streams

View File

@ -1,11 +1,13 @@
---
title: percentile() function
description: The percentile() function outputs non-null records with values that fall within the specified percentile or the non-null record with the value that represents the specified percentile.
aliases:
- /v2.0/reference/flux/functions/transformations/aggregates/percentile
menu:
v2_0_ref:
name: percentile
parent: Aggregates
weight: 401
parent: built-in-aggregates
weight: 501
---
The `percentile()` function returns records from an input table with `_value`s that fall within

View File

@ -1,11 +1,13 @@
---
title: skew() function
description: The skew() function outputs the skew of non-null records as a float.
aliases:
- /v2.0/reference/flux/functions/transformations/aggregates/skew
menu:
v2_0_ref:
name: skew
parent: Aggregates
weight: 401
parent: built-in-aggregates
weight: 501
---
The `skew()` function outputs the skew of non-null records as a float.

View File

@ -1,11 +1,13 @@
---
title: spread() function
description: The spread() function outputs the difference between the minimum and maximum values in each specified column.
aliases:
- /v2.0/reference/flux/functions/transformations/aggregates/spread
menu:
v2_0_ref:
name: spread
parent: Aggregates
weight: 401
parent: built-in-aggregates
weight: 501
---
The `spread()` function outputs the difference between the minimum and maximum values in each specified column.

View File

@ -1,11 +1,13 @@
---
title: stddev() function
description: The stddev() function computes the standard deviation of non-null records in specified columns.
aliases:
- /v2.0/reference/flux/functions/transformations/aggregates/stddev
menu:
v2_0_ref:
name: stddev
parent: Aggregates
weight: 401
parent: built-in-aggregates
weight: 501
---
The `stddev()` function computes the standard deviation of non-null records in specified columns.

View File

@ -1,11 +1,13 @@
---
title: sum() function
description: The sum() function computes the sum of non-null records in specified columns.
aliases:
- /v2.0/reference/flux/functions/transformations/aggregates/sum
menu:
v2_0_ref:
name: sum
parent: Aggregates
weight: 401
parent: built-in-aggregates
weight: 501
---
The `sum()` function computes the sum of non-null records in specified columns.

View File

@ -3,12 +3,14 @@ title: columns() function
description: >
The columns() function lists the column labels of input tables.
For each input table, it outputs a table with the same group key columns,
plus a new column containing the labels of the input table's columns.
plus a new column containing the labels of the input table's columns.
aliases:
- /v2.0/reference/flux/functions/transformations/columns
menu:
v2_0_ref:
name: columns
parent: Transformations
weight: 301
parent: built-in-transformations
weight: 401
---
The `columns()` function lists the column labels of input tables.

View File

@ -1,11 +1,13 @@
---
title: cumulativeSum() function
description: The cumulativeSum() function computes a running sum for non-null records in the table.
aliases:
- /v2.0/reference/flux/functions/transformations/cumulativesum
menu:
v2_0_ref:
name: cumulativeSum
parent: Transformations
weight: 301
parent: built-in-transformations
weight: 401
---
The `cumulativeSum()` function computes a running sum for non-null records in the table.

View File

@ -1,11 +1,13 @@
---
title: drop() function
description: The drop() function removes specified columns from a table.
aliases:
- /v2.0/reference/flux/functions/transformations/drop
menu:
v2_0_ref:
name: drop
parent: Transformations
weight: 301
parent: built-in-transformations
weight: 401
---
The `drop()` function removes specified columns from a table.

View File

@ -1,11 +1,13 @@
---
title: duplicate() function
description: The duplicate() function duplicates a specified column in a table.
aliases:
- /v2.0/reference/flux/functions/transformations/duplicate
menu:
v2_0_ref:
name: duplicate
parent: Transformations
weight: 301
parent: built-in-transformations
weight: 401
---
The `duplicate()` function duplicates a specified column in a table.

View File

@ -1,11 +1,13 @@
---
title: fill() function
description: The fill() function replaces all null values in an input stream and replace them with a non-null value.
aliases:
- /v2.0/reference/flux/functions/transformations/fill
menu:
v2_0_ref:
name: fill
parent: Transformations
weight: 301
parent: built-in-transformations
weight: 401
---
The `fill()` function replaces all null values in an input stream with a non-null value.

View File

@ -1,11 +1,13 @@
---
title: filter() function
description: The filter() function filters data based on conditions defined in a predicate function (fn).
aliases:
- /v2.0/reference/flux/functions/transformations/filter
menu:
v2_0_ref:
name: filter
parent: Transformations
weight: 301
parent: built-in-transformations
weight: 401
---
The `filter()` function filters data based on conditions defined in a predicate function ([`fn`](#fn)).

View File

@ -1,11 +1,13 @@
---
title: group() function
description: The group() function groups records based on their values for specific columns.
aliases:
- /v2.0/reference/flux/functions/transformations/group
menu:
v2_0_ref:
name: group
parent: Transformations
weight: 301
parent: built-in-transformations
weight: 401
---
The `group()` function groups records based on their values for specific columns.

View File

@ -1,11 +1,13 @@
---
title: histogram() function
description: The histogram() function approximates the cumulative distribution of a dataset by counting data frequencies for a list of bins.
aliases:
- /v2.0/reference/flux/functions/transformations/histogram
menu:
v2_0_ref:
name: histogram
parent: Transformations
weight: 301
parent: built-in-transformations
weight: 401
---
The `histogram()` function approximates the cumulative distribution of a dataset by counting data frequencies for a list of bins.

View File

@ -1,11 +1,13 @@
---
title: join() function
description: The join() function merges two or more input streams whose values are equal on a set of common columns into a single output stream.
aliases:
- /v2.0/reference/flux/functions/transformations/join
menu:
v2_0_ref:
name: join
parent: Transformations
weight: 301
parent: built-in-transformations
weight: 401
---
The `join()` function merges two or more input streams whose values are equal on

View File

@ -1,11 +1,13 @@
---
title: keep() function
description: The keep() function returns a table containing only the specified columns.
aliases:
- /v2.0/reference/flux/functions/transformations/keep
menu:
v2_0_ref:
name: keep
parent: Transformations
weight: 301
parent: built-in-transformations
weight: 401
---
The `keep()` function returns a table containing only the specified columns, ignoring all others.

View File

@ -3,12 +3,14 @@ title: keys() function
description: >
The keys() function outputs the group key of input tables.
For each input table, it outputs a table with the same group key columns, plus a
_value column containing the labels of the input table's group key.
_value column containing the labels of the input table's group key.
aliases:
- /v2.0/reference/flux/functions/transformations/keys
menu:
v2_0_ref:
name: keys
parent: Transformations
weight: 301
parent: built-in-transformations
weight: 401
---
The `keys()` function outputs the group key of input tables.

View File

@ -1,11 +1,13 @@
---
title: keyValues() function
description: The keyValues() function returns a table with the input table's group key plus two columns, _key and _value, that correspond to unique column + value pairs from the input table.
aliases:
- /v2.0/reference/flux/functions/transformations/keyvalues
menu:
v2_0_ref:
name: keyValues
parent: Transformations
weight: 301
parent: built-in-transformations
weight: 401
---
The `keyValues()` function returns a table with the input table's group key plus two columns,

View File

@ -1,11 +1,13 @@
---
title: limit() function
description: The limit() function limits the number of records in output tables to a fixed number (n).
aliases:
- /v2.0/reference/flux/functions/transformations/limit
menu:
v2_0_ref:
name: limit
parent: Transformations
weight: 301
parent: built-in-transformations
weight: 401
---
The `limit()` function limits the number of records in output tables to a fixed number ([`n`](#n)).

View File

@ -1,11 +1,13 @@
---
title: map() function
description: The map() function applies a function to each record in the input tables.
aliases:
- /v2.0/reference/flux/functions/transformations/map
menu:
v2_0_ref:
name: map
parent: Transformations
weight: 301
parent: built-in-transformations
weight: 401
---
The `map()` function applies a function to each record in the input tables.

View File

@ -1,11 +1,13 @@
---
title: pivot() function
description: The pivot() function collects values stored vertically (column-wise) in a table and aligns them horizontally (row-wise) into logical sets.
aliases:
- /v2.0/reference/flux/functions/transformations/pivot
menu:
v2_0_ref:
name: pivot
parent: Transformations
weight: 301
parent: built-in-transformations
weight: 401
---
The `pivot()` function collects values stored vertically (column-wise) in a table

View File

@ -1,11 +1,13 @@
---
title: range() function
description: The range() function filters records based on time bounds.
aliases:
- /v2.0/reference/flux/functions/transformations/range
menu:
v2_0_ref:
name: range
parent: Transformations
weight: 301
parent: built-in-transformations
weight: 401
---
The `range()` function filters records based on time bounds.

View File

@ -1,11 +1,13 @@
---
title: rename() function
description: The rename() function renames specified columns in a table.
aliases:
- /v2.0/reference/flux/functions/transformations/rename
menu:
v2_0_ref:
name: rename
parent: Transformations
weight: 301
parent: built-in-transformations
weight: 401
---
The `rename()` function renames specified columns in a table.

View File

@ -1,11 +1,14 @@
---
title: Flux selector functions
description: Flux selector functions return one or more records based on function logic.
aliases:
- /v2.0/reference/flux/functions/transformations/selectors
menu:
v2_0_ref:
parent: Transformations
parent: built-in-transformations
name: Selectors
weight: 301
identifier: built-in-selectors
weight: 401
---
Flux selector functions return one or more records based on function logic.

View File

@ -1,11 +1,13 @@
---
title: bottom() function
description: The bottom() function sorts a table by columns and keeps only the bottom n records.
aliases:
- /v2.0/reference/flux/functions/transformations/selectors/bottom
menu:
v2_0_ref:
name: bottom
parent: Selectors
weight: 401
parent: built-in-selectors
weight: 501
---
The `bottom()` function sorts a table by columns and keeps only the bottom `n` records.

View File

@ -1,11 +1,13 @@
---
title: distinct() function
description: The distinct() function returns the unique values for a given column.
aliases:
- /v2.0/reference/flux/functions/transformations/selectors/distinct
menu:
v2_0_ref:
name: distinct
parent: Selectors
weight: 401
parent: built-in-selectors
weight: 501
---
The `distinct()` function returns the unique values for a given column.

View File

@ -1,11 +1,13 @@
---
title: first() function
description: The first() function selects the first non-null record from an input table.
aliases:
- /v2.0/reference/flux/functions/transformations/selectors/first
menu:
v2_0_ref:
name: first
parent: Selectors
weight: 401
parent: built-in-selectors
weight: 501
---
The `first()` function selects the first non-null record from an input table.

View File

@ -1,11 +1,13 @@
---
title: highestAverage() function
description: The highestAverage() function returns the top 'n' records from all groups using the average of each group.
aliases:
- /v2.0/reference/flux/functions/transformations/selectors/highestaverage
menu:
v2_0_ref:
name: highestAverage
parent: Selectors
weight: 401
parent: built-in-selectors
weight: 501
---
The `highestAverage()` function returns the top `n` records from all groups using the average of each group.

View File

@ -1,11 +1,13 @@
---
title: highestCurrent() function
description: The highestCurrent() function returns the top 'n' records from all groups using the last value of each group.
aliases:
- /v2.0/reference/flux/functions/transformations/selectors/highestcurrent
menu:
v2_0_ref:
name: highestCurrent
parent: Selectors
weight: 401
parent: built-in-selectors
weight: 501
---
The `highestCurrent()` function returns the top `n` records from all groups using the last value of each group.

View File

@ -1,11 +1,13 @@
---
title: highestMax() function
description: The highestMax() function returns the top 'n' records from all groups using the maximum of each group.
aliases:
- /v2.0/reference/flux/functions/transformations/selectors/highestmax
menu:
v2_0_ref:
name: highestMax
parent: Selectors
weight: 401
parent: built-in-selectors
weight: 501
---
The `highestMax()` function returns the top `n` records from all groups using the maximum of each group.

View File

@ -1,11 +1,13 @@
---
title: last() function
description: The last() function selects the last non-null record from an input table.
aliases:
- /v2.0/reference/flux/functions/transformations/selectors/last
menu:
v2_0_ref:
name: last
parent: Selectors
weight: 401
parent: built-in-selectors
weight: 501
---
The `last()` function selects the last non-null record from an input table.

View File

@ -1,11 +1,13 @@
---
title: lowestAverage() function
description: The lowestAverage() function returns the bottom 'n' records from all groups using the average of each group.
aliases:
- /v2.0/reference/flux/functions/transformations/selectors/lowestaverage
menu:
v2_0_ref:
name: lowestAverage
parent: Selectors
weight: 401
parent: built-in-selectors
weight: 501
---
The `lowestAverage()` function returns the bottom `n` records from all groups using the average of each group.

View File

@ -1,11 +1,13 @@
---
title: lowestCurrent() function
description: The lowestCurrent() function returns the bottom 'n' records from all groups using the last value of each group.
aliases:
- /v2.0/reference/flux/functions/transformations/selectors/lowestcurrent
menu:
v2_0_ref:
name: lowestCurrent
parent: Selectors
weight: 401
parent: built-in-selectors
weight: 501
---
The `lowestCurrent()` function returns the bottom `n` records from all groups using the last value of each group.

View File

@ -1,11 +1,13 @@
---
title: lowestMin() function
description: The lowestMin() function returns the bottom 'n' records from all groups using the minimum of each group.
aliases:
- /v2.0/reference/flux/functions/transformations/selectors/lowestmin
menu:
v2_0_ref:
name: lowestMin
parent: Selectors
weight: 401
parent: built-in-selectors
weight: 501
---
The `lowestMin()` function returns the bottom `n` records from all groups using the minimum of each group.

View File

@ -1,11 +1,13 @@
---
title: max() function
description: The max() function selects record with the highest _value from the input table.
aliases:
- /v2.0/reference/flux/functions/transformations/selectors/max
menu:
v2_0_ref:
name: max
parent: Selectors
weight: 401
parent: built-in-selectors
weight: 501
---
The `max()` function selects record with the highest `_value` from the input table.

View File

@ -1,11 +1,13 @@
---
title: min() function
description: The min() function selects record with the lowest _value from the input table.
aliases:
- /v2.0/reference/flux/functions/transformations/selectors/min
menu:
v2_0_ref:
name: min
parent: Selectors
weight: 401
parent: built-in-selectors
weight: 501
---
The `min()` function selects record with the lowest `_value` from the input table.

View File

@ -1,11 +1,13 @@
---
title: sample() function
description: The sample() function selects a subset of the records from the input table.
aliases:
- /v2.0/reference/flux/functions/transformations/selectors/sample
menu:
v2_0_ref:
name: sample
parent: Selectors
weight: 401
parent: built-in-selectors
weight: 501
---
The `sample()` function selects a subset of the records from the input table.

View File

@ -1,11 +1,13 @@
---
title: top() function
description: The top() function sorts a table by columns and keeps only the top n records.
aliases:
- /v2.0/reference/flux/functions/transformations/selectors/top
menu:
v2_0_ref:
name: top
parent: Selectors
weight: 401
parent: built-in-selectors
weight: 501
---
The `top()` function sorts a table by columns and keeps only the top `n` records.

View File

@ -1,11 +1,13 @@
---
title: unique() function
description: The unique() function returns all records containing unique values in a specified column.
aliases:
- /v2.0/reference/flux/functions/transformations/selectors/unique
menu:
v2_0_ref:
name: unique
parent: Selectors
weight: 401
parent: built-in-selectors
weight: 501
---
The `unique()` function returns all records containing unique values in a specified column.

View File

@ -1,11 +1,13 @@
---
title: set() function
description: The set() function assigns a static value to each record in the input table.
aliases:
- /v2.0/reference/flux/functions/transformations/set
menu:
v2_0_ref:
name: set
parent: Transformations
weight: 301
parent: built-in-transformations
weight: 401
---
The `set()` function assigns a static value to each record in the input table.

View File

@ -1,11 +1,13 @@
---
title: shift() function
description: The shift() function adds a fixed duration to time columns.
aliases:
- /v2.0/reference/flux/functions/transformations/shift
menu:
v2_0_ref:
name: shift
parent: Transformations
weight: 301
parent: built-in-transformations
weight: 401
---
The `shift()` function adds a fixed duration to time columns.

View File

@ -1,11 +1,13 @@
---
title: sort() function
description: The sort() function orders the records within each table.
aliases:
- /v2.0/reference/flux/functions/transformations/sort
menu:
v2_0_ref:
name: sort
parent: Transformations
weight: 301
parent: built-in-transformations
weight: 401
---
The `sort()` function orders the records within each table.

View File

@ -1,11 +1,13 @@
---
title: stateCount() function
description: The stateCount() function computes the number of consecutive records in a given state.
aliases:
- /v2.0/reference/flux/functions/transformations/statecount
menu:
v2_0_ref:
name: stateCount
parent: Transformations
weight: 301
parent: built-in-transformations
weight: 401
---
The `stateCount()` function computes the number of consecutive records in a given state.

View File

@ -1,11 +1,13 @@
---
title: stateDuration() function
description: The stateDuration() function computes the duration of a given state.
aliases:
- /v2.0/reference/flux/functions/transformations/stateduration
menu:
v2_0_ref:
name: stateDuration
parent: Transformations
weight: 301
parent: built-in-transformations
weight: 401
---
The `stateDuration()` function computes the duration of a given state.

View File

@ -1,11 +1,14 @@
---
title: Flux type conversion functions
description: Flux type conversion functions convert columns of the input table into a specific data type.
aliases:
- /v2.0/reference/flux/functions/transformations/type-conversions
menu:
v2_0_ref:
parent: Transformations
parent: built-in-transformations
name: Type conversions
weight: 301
identifier: built-in-type-conversions
weight: 401
---
Flux type conversion functions convert columns of the input table into a specific data type.

View File

@ -1,11 +1,13 @@
---
title: toBool() function
description: The toBool() function converts a value to a boolean.
aliases:
- /v2.0/reference/flux/functions/transformations/type-conversions/tobool
menu:
v2_0_ref:
name: toBool
parent: Type conversions
weight: 401
parent: built-in-type-conversions
weight: 501
---
The `toBool()` function converts a value to a boolean.

View File

@ -1,11 +1,13 @@
---
title: toDuration() function
description: The toDuration() function converts a value to a duration.
aliases:
- /v2.0/reference/flux/functions/transformations/type-conversions/toduration
menu:
v2_0_ref:
name: toDuration
parent: Type conversions
weight: 401
parent: built-in-type-conversions
weight: 501
---
The `toDuration()` function converts a value to a duration.

View File

@ -1,11 +1,13 @@
---
title: toFloat() function
description: The toFloat() function converts a value to a float.
aliases:
- /v2.0/reference/flux/functions/transformations/type-conversions/tofloat
menu:
v2_0_ref:
name: toFloat
parent: Type conversions
weight: 401
parent: built-in-type-conversions
weight: 501
---
The `toFloat()` function converts a value to a float.

View File

@ -1,11 +1,13 @@
---
title: toInt() function
description: The toInt() function converts a value to an integer.
aliases:
- /v2.0/reference/flux/functions/transformations/type-conversions/toint
menu:
v2_0_ref:
name: toInt
parent: Type conversions
weight: 401
parent: built-in-type-conversions
weight: 501
---
The `toInt()` function converts a value to an integer.

View File

@ -1,11 +1,13 @@
---
title: toString() function
description: The toString() function converts a value to a string.
aliases:
- /v2.0/reference/flux/functions/transformations/type-conversions/tostring
menu:
v2_0_ref:
name: toString
parent: Type conversions
weight: 401
parent: built-in-type-conversions
weight: 501
---
The `toString()` function converts a value to a string.

View File

@ -1,11 +1,13 @@
---
title: toTime() function
description: The toTime() function converts a value to a time.
aliases:
- /v2.0/reference/flux/functions/transformations/type-conversions/totime
menu:
v2_0_ref:
name: toTime
parent: Type conversions
weight: 401
parent: built-in-type-conversions
weight: 501
---
The `toTime()` function converts a value to a time.

View File

@ -1,11 +1,13 @@
---
title: toUInt() function
description: The toUInt() function converts a value to an uinteger.
aliases:
- /v2.0/reference/flux/functions/transformations/type-conversions/touint
menu:
v2_0_ref:
name: toUInt
parent: Type conversions
weight: 401
parent: built-in-type-conversions
weight: 501
---
The `toUInt()` function converts a value to an UInteger.

View File

@ -1,11 +1,13 @@
---
title: union() function
description: The union() function concatenates two or more input streams into a single output stream.
aliases:
- /v2.0/reference/flux/functions/transformations/union
menu:
v2_0_ref:
name: union
parent: Transformations
weight: 301
parent: built-in-transformations
weight: 401
---
The `union()` function concatenates two or more input streams into a single output stream.

View File

@ -1,11 +1,13 @@
---
title: window() function
description: The window() function groups records based on a time value.
aliases:
- /v2.0/reference/flux/functions/transformations/window
menu:
v2_0_ref:
name: window
parent: Transformations
weight: 301
parent: built-in-transformations
weight: 401
---
The `window()` function groups records based on a time value.
@ -14,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_
@ -21,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
@ -33,7 +39,8 @@ window(
intervals: intervals(every: 5m, period: 5m, offset: 12h),
timeColumn: "_time",
startColumn: "_start",
stopColumn: "_stop"
stopColumn: "_stop",
createEmpty: false
)
```
@ -57,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_
@ -96,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

View File

@ -0,0 +1,22 @@
---
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.
To use them, import the "influxdata/influxdb/v1" package.
menu:
v2_0_ref:
name: InfluxDB v1
parent: Flux functions
weight: 202
---
InfluxDB v1 Flux functions provide tools for managing data from an InfluxDB v1.x
database or structured using the InfluxDB v1 data structure.
To use them, import the `influxdata/influxdb/v1` package:
```js
import "influxdata/influxdb/v1"
```
{{< children type="functions" show="pages" >}}

View File

@ -0,0 +1,48 @@
---
title: v1.fieldsAsCols() function
description: The v1.fieldsAsCols() function is pivots a table and automatically aligns fields within each input table that have the same timestamp.
aliases:
- /v2.0/reference/flux/functions/inputs/fromrows
- /v2.0/reference/flux/functions/transformations/influxfieldsascols
menu:
v2_0_ref:
name: v1.fieldsAsCols
parent: InfluxDB v1
weight: 301
---
The `v1.fieldsAsCols()` function is a special application of the `pivot()` function that
automatically aligns fields within each input table that have the same timestamp.
_**Function type:** Transformation_
```js
import "influxdata/influxdb/v1"
v1.fieldsAsCols()
```
## Examples
```js
import "influxdata/influxdb/v1"
from(bucket:"telegraf/autogen")
|> range(start: -1h)
|> filter(fn: (r) => r._measurement == "cpu")
|> v1.fieldsAsCols()
|> keep(columns: ["_time", "cpu", "usage_idle", "usage_user"])
```
## Function definition
```js
fieldsAsCols = (tables=<-) =>
tables
|> pivot(
rowKey:["_time"],
columnKey: ["_field"],
valueColumn: "_value"
)
```
_**Used functions:**
[pivot()](/v2.0/reference/flux/functions/built-in/transformations/pivot)_

View File

@ -0,0 +1,34 @@
---
title: v1.measurements() function
description: The v1.measurements() function returns a list of measurements in a specific bucket.
menu:
v2_0_ref:
name: v1.measurements
parent: InfluxDB v1
weight: 301
---
The `v1.measurements()` function returns a list of measurements in a specific bucket.
The return value is always a single table with a single column, `_value`.
```js
import "influxdata/influxdb/v1"
v1.measurements(bucket: "example-bucket")
```
## Parameters
### bucket
The bucket from which to list measurements.
_**Data type:** String_
## Function definition
```js
measurements = (bucket) =>
tagValues(bucket: bucket, tag: "_measurement")
```
_**Used functions:**
[tagValues()](/v2.0/reference/flux/functions/influxdb-v1/tagvalues)_

View File

@ -0,0 +1,44 @@
---
title: v1.measurementTagKeys() function
description: The v1.measurementTagKeys() function returns a list of tag keys for a specific measurement.
menu:
v2_0_ref:
name: v1.measurementTagKeys
parent: InfluxDB v1
weight: 301
---
The `v1.measurementTagKeys()` function returns a list of tag keys for a specific measurement.
The return value is always a single table with a single column, `_value`.
```js
import "influxdata/influxdb/v1"
v1.measurementTagKeys(
bucket: "example-bucket",
measurement: "cpu"
)
```
## Parameters
### bucket
The bucket from which to return tag keys for a specific measurement.
_**Data type:** String_
### measurement
The measurement from which to return tag keys.
_**Data type:** String_
## Function definition
```js
measurementTagKeys = (bucket, measurement) =>
tagKeys(
bucket: bucket,
predicate: (r) => r._measurement == measurement)
```
_**Used functions:**
[tagKeys()](/v2.0/reference/flux/functions/influxdb-v1/tagkeys)_

View File

@ -0,0 +1,55 @@
---
title: v1.measurementTagValues() function
description: The v1.measurementTagValues() function returns a list of tag values for a specific measurement.
menu:
v2_0_ref:
name: v1.measurementTagValues
parent: InfluxDB v1
weight: 301
---
The `v1.measurementTagValues()` function returns a list of tag values for a specific measurement.
The return value is always a single table with a single column, `_value`.
```js
import "influxdata/influxdb/v1"
v1.measurementTagValues(
bucket: "example-bucket",
measurement: "cpu",
tag: "host"
)
```
## Parameters
### bucket
The bucket from which to return tag values for a specific measurement.
_**Data type:** String_
### measurement
The measurement from which to return tag values.
_**Data type:** String_
### tag
The tag from which to return all unique values.
_**Data type:** String_
## Function definition
```js
measurementTagValues = (bucket, measurement, tag) =>
tagValues(
bucket: bucket,
tag: tag,
predicate: (r) => r._measurement == measurement
)
```
_**Used functions:**
[tagValues()](/v2.0/reference/flux/functions/influxdb-v1/tagvalues)_

View File

@ -0,0 +1,70 @@
---
title: v1.tagKeys() function
description: The v1.tagKeys() function returns a list of tag keys for all series that match the predicate.
menu:
v2_0_ref:
name: v1.tagKeys
parent: InfluxDB v1
weight: 301
---
The `v1.tagKeys()` function returns a list of tag keys for all series that match the [`predicate`](#predicate).
The return value is always a single table with a single column, `_value`.
```js
import "influxdata/influxdb/v1"
v1.tagKeys(
bucket: "example-bucket",
predicate: (r) => true,
start: -30d
)
```
## Parameters
### bucket
The bucket from which to list tag keys.
_**Data type:** String_
### predicate
The predicate function that filters tag keys.
_Defaults to `(r) => true`._
_**Data type:** Function_
### start
Specifies the oldest time to be included in the results.
_Defaults to `-30d`._
Relative start times are defined using negative durations.
Negative durations are relative to now.
Absolute start times are defined using timestamps.
_**Data type:** Duration_
## Examples
```js
import "influxdata/influxdb/v1"
v1.tagKeys(bucket: "my-bucket")
```
## Function definition
```js
tagKeys = (bucket, predicate=(r) => true, start=-30d) =>
from(bucket: bucket)
|> range(start: start)
|> filter(fn: predicate)
|> keys()
|> keep(columns: ["_value"])
```
_**Used functions:**
[from](/v2.0/reference/flux/functions/built-in/inputs/from/),
[range](/v2.0/reference/flux/functions/built-in/transformations/range/),
[filter](/v2.0/reference/flux/functions/built-in/transformations/filter/),
[keys](/v2.0/reference/flux/functions/built-in/transformations/keys/),
[keep](/v2.0/reference/flux/functions/built-in/transformations/keep/)_

View File

@ -0,0 +1,81 @@
---
title: v1.tagValues() function
description: placeholder
menu:
v2_0_ref:
name: v1.tagValues
parent: InfluxDB v1
weight: 301
---
The `v1.tagValues()` function returns a list unique values for a given tag.
The return value is always a single table with a single column, `_value`.
```js
import "influxdata/influxdb/v1"
v1.tagValues(
bucket: "example-bucket",
tag: "host",
predicate: (r) => true,
start: -30d
)
```
## Parameters
### bucket
The bucket from which to list tag values.
_**Data type:** String_
### tag
The tag for which to return unique values.
_**Data type:** String_
### predicate
The predicate function that filters tag values.
_Defaults to `(r) => true`._
_**Data type:** Function_
### start
Specifies the oldest time to be included in the results.
_Defaults to `-30d`._
Relative start times are defined using negative durations.
Negative durations are relative to now.
Absolute start times are defined using timestamps.
_**Data type:** Duration_
## Examples
```js
import "influxdata/influxdb/v1"
v1.tagKeys(
bucket: "my-bucket",
tag: "host",
)
```
## Function definition
```js
tagValues = (bucket, tag, predicate=(r) => true, start=-30d) =>
from(bucket: bucket)
|> range(start: start)
|> filter(fn: predicate)
|> group(columns: [tag])
|> distinct(column: tag)
|> keep(columns: ["_value"])
```
_**Used functions:**
[from](/v2.0/reference/flux/functions/built-in/inputs/from/),
[range](/v2.0/reference/flux/functions/built-in/transformations/range/),
[filter](/v2.0/reference/flux/functions/built-in/transformations/filter/),
[group](/v2.0/reference/flux/functions/built-in/transformations/group/),
[distinct](/v2.0/reference/flux/functions/built-in/transformations/selectors/distinct/),
[keep](/v2.0/reference/flux/functions/built-in/transformations/keep/)_

View File

@ -0,0 +1,20 @@
---
title: Flux string functions
description: >
String functions provide tools for manipulating strings in Flux.
To use them, import the "strings" package.
menu:
v2_0_ref:
name: Strings
parent: Flux functions
weight: 203
---
String functions provide tools for manipulating strings in Flux.
To use them, import the `strings` package:
```js
import "strings"
```
{{< children type="functions" show="pages" >}}

View File

@ -0,0 +1,38 @@
---
title: strings.title() function
description: The strings.title() function converts a string to title case.
menu:
v2_0_ref:
name: strings.title
parent: Strings
weight: 301
---
The `strings.title()` function converts a string to title case.
_**Output data type:** String_
```js
import "strings"
strings.title(v: "a flux of foxes")
// returns "A Flux Of Foxes"
```
## Paramters
### v
The string value to convert.
_**Data type:** String_
## Examples
###### Convert all values of a column to title case
```js
import "strings"
data
|> map(fn:(r) => strings.title(v: r.pageTitle))
```

View File

@ -0,0 +1,38 @@
---
title: strings.toLower() function
description: The strings.toLower() function converts a string to lower case.
menu:
v2_0_ref:
name: strings.toLower
parent: Strings
weight: 301
---
The `strings.toLower()` function converts a string to lower case.
_**Output data type:** String_
```js
import "strings"
strings.toLower(v: "KOALA")
// returns "koala"
```
## Paramters
### v
The string value to convert.
_**Data type:** String_
## Examples
###### Convert all values of a column to lower case
```js
import "strings"
data
|> map(fn:(r) => strings.toLower(v: r.exclamation))
```

View File

@ -0,0 +1,38 @@
---
title: strings.toUpper() function
description: The strings.toUpper() function converts a string to upper case.
menu:
v2_0_ref:
name: strings.toUpper
parent: Strings
weight: 301
---
The `strings.toUpper()` function converts a string to upper case.
_**Output data type:** String_
```js
import "strings"
strings.toUpper(v: "koala")
// returns "KOALA"
```
## Paramters
### v
The string value to convert.
_**Data type:** String_
## Examples
###### Convert all values of a column to upper case
```js
import "strings"
data
|> map(fn:(r) => strings.toUpper(v: r.envVars))
```

View File

@ -0,0 +1,47 @@
---
title: strings.trim() function
description: >
The strings.trim() function removes leading and trailing characters specified
in the cutset from a string.
menu:
v2_0_ref:
name: strings.trim
parent: Strings
weight: 301
---
The `strings.trim()` function removes leading and trailing characters specified
in the [`cutset`](#cutset) from a string.
_**Output data type:** String_
```js
import "strings"
strings.trim(v: ".abc.", cutset: ".")
// returns "abc"
```
## Paramters
### v
The string value from which to trim characters.
_**Data type:** String_
### cutset
The leading and trailing characters to trim from the string value.
Only characters that match the `cutset` string exactly are trimmed.
_**Data type:** String_
## Examples
###### Trim leading and trailing periods from all values in a column
```js
import "strings"
data
|> map(fn:(r) => strings.trim(v: r.variables, cutset: "."))
```

View File

@ -0,0 +1,38 @@
---
title: strings.trimSpace() function
description: The strings.trimSpace() function removes leading and trailing spaces from a string.
menu:
v2_0_ref:
name: strings.trimSpace
parent: Strings
weight: 301
---
The `strings.trimSpace()` function removes leading and trailing spaces from a string.
_**Output data type:** String_
```js
import "strings"
strings.trimSpace(v: " abc ")
// returns "abc"
```
## Paramters
### v
The string value from which to trim spaces.
_**Data type:** String_
## Examples
###### Trim leading and trailing spaces from all values in a column
```js
import "strings"
data
|> map(fn:(r) => strings.trimSpace(v: r.userInput))
```

View File

@ -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" >}}

View File

@ -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 returns 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()
```

View File

@ -1,43 +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: Tests
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_
If unequal, the function returns an error.
```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_
@ -47,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)
```

View File

@ -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)
```

View File

@ -1,14 +0,0 @@
---
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: Tests
parent: Flux functions
weight: 205
---
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" >}}

View File

@ -1,40 +0,0 @@
---
title: influxFieldsAsCols() function
description: The influxFieldsAsCols() function is pivots a table and automatically aligns fields within each input table that have the same timestamp.
aliases:
- /v2.0/reference/flux/functions/inputs/fromrows
menu:
v2_0_ref:
name: influxFieldsAsCols
parent: Transformations
weight: 301
---
The `influxFieldsAsCols()` function is a special application of the `pivot()` function that
automatically aligns fields within each input table that have the same timestamp.
_**Function type:** Transformation_
```js
influxFieldsAsCols()
```
## Examples
```js
from(bucket:"telegraf/autogen")
|> range(start: -1h)
|> filter(fn: (r) => r._measurement == "cpu")
|> influxFieldsAsCols()
|> keep(columns: ["_time", "cpu", "usage_idle", "usage_user"])
```
## Function definition
```js
influxFieldsAsCols = (tables=<-) =>
tables
|> pivot(
rowKey:["_time"],
columnKey: ["_field"],
valueColumn: "_value"
)
```