updated duration example, commented out fn param on keyValues
parent
e613b89efb
commit
a72885dfab
|
@ -21,21 +21,25 @@ The `keyValues()` function returns a table with the input table's group key plus
|
|||
`_key` and `_value`, that correspond to unique column + value pairs from the input table.
|
||||
|
||||
_**Function type:** Transformation_
|
||||
_**Output data type:** Object_
|
||||
|
||||
```js
|
||||
keyValues(keyColumns: ["usage_idle", "usage_user"])
|
||||
```
|
||||
|
||||
<!--
|
||||
```js
|
||||
// OR
|
||||
|
||||
keyValues(fn: (schema) => schema.columns |> filter(fn: (r) => r.label =~ /usage_.*/))
|
||||
```
|
||||
``` -->
|
||||
|
||||
## Parameters
|
||||
|
||||
<!--
|
||||
{{% note %}}
|
||||
`keyColumns` and `fn` are mutually exclusive. Only one may be used at a time.
|
||||
{{% /note %}}
|
||||
-->
|
||||
|
||||
### keyColumns
|
||||
|
||||
|
@ -45,6 +49,7 @@ Each input table must have all of the columns listed by the `keyColumns` paramet
|
|||
|
||||
_**Data type:** Array of strings_
|
||||
|
||||
<!--
|
||||
### fn
|
||||
|
||||
Function used to identify a set of columns.
|
||||
|
@ -61,6 +66,7 @@ _**Data type:** Function_
|
|||
- Only one of `keyColumns` or `fn` may be used in a single call.
|
||||
- All columns indicated must be of the same type.
|
||||
- Each input table must have all of the columns listed by the `keyColumns` parameter.
|
||||
-->
|
||||
|
||||
## Examples
|
||||
|
||||
|
@ -73,6 +79,7 @@ from(bucket: "example-bucket")
|
|||
|> keyValues(keyColumns: ["usage_idle", "usage_user"])
|
||||
```
|
||||
|
||||
<!--
|
||||
##### Get key values from columns matching a regular expression
|
||||
|
||||
```js
|
||||
|
@ -80,4 +87,5 @@ from(bucket: "example-bucket")
|
|||
|> range(start: -30m)
|
||||
|> filter(fn: (r) => r._measurement == "cpu")
|
||||
|> keyValues(fn: (schema) => schema.columns |> filter(fn: (r) => r.label =~ /usage_.*/))
|
||||
```
|
||||
```
|
||||
-->
|
||||
|
|
|
@ -32,9 +32,15 @@ _**Data type:** Integer | String | Uinteger_
|
|||
{{% /note %}}
|
||||
|
||||
## Examples
|
||||
|
||||
{{% note %}}
|
||||
Flux does not support duration column types.
|
||||
The example below converts an integer to a duration and stores the value as a string.
|
||||
{{% /note %}}
|
||||
|
||||
```js
|
||||
from(bucket: "sensor-data")
|
||||
|> range(start: -1m)
|
||||
|> filter(fn:(r) => r._measurement == "system" )
|
||||
|> map(fn:(r) => ({ r with uptime: duration(v: r.uptime) }))
|
||||
|> map(fn:(r) => ({ r with uptime: string(v: duration(v: r.uptime)) }))
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue