hotfix: fixed stream and table function examples
parent
1b514943ce
commit
fba827d8b4
|
@ -17,41 +17,4 @@ related:
|
|||
- /influxdb/cloud/query-data/flux/scalar-values/
|
||||
---
|
||||
|
||||
Use stream and table functions to extract a table from a stream of tables and access its
|
||||
columns and records.
|
||||
|
||||
{{< children type="functions" >}}
|
||||
|
||||
### Example stream and table functions
|
||||
|
||||
##### Recommended usage
|
||||
```js
|
||||
data = from(bucket:"example-bucket")
|
||||
|> range(start: -5m)
|
||||
|> filter(fn:(r) => r._measurement == "cpu")
|
||||
|
||||
// Extract the "_value" column from the table
|
||||
data
|
||||
|> findColumn(fn: (key) => key._field == "usage_idle", column: "_value")
|
||||
|
||||
// Extract the first record from the table
|
||||
data
|
||||
|> findRecord(fn: (key) => key._field == "usage_idle", idx: 0)
|
||||
|
||||
```
|
||||
|
||||
##### Alternate usage
|
||||
```js
|
||||
data = from(bucket:"example-bucket")
|
||||
|> range(start: -5m)
|
||||
|> filter(fn:(r) => r._measurement == "cpu")
|
||||
|
||||
// Extract the first available table for which "_field" is equal to "usage_idle"
|
||||
t = data |> tableFind(fn: (key) => key._field == "usage_idle")
|
||||
|
||||
// Extract the "_value" column from the table
|
||||
values = t |> getColumn(column: "_value")
|
||||
|
||||
// Extract the first record from the table
|
||||
r0 = t |> getRecord(idx: 0)
|
||||
```
|
||||
{{< duplicate-oss >}}
|
||||
|
|
|
@ -12,43 +12,4 @@ related:
|
|||
- /influxdb/cloud/query-data/flux/scalar-values/
|
||||
---
|
||||
|
||||
The `findColumn()` function returns an array of values in a specified column from the
|
||||
first table in a stream of tables where the group key values match the specified predicate.
|
||||
The function returns an empty array if no table is found or if the column label
|
||||
is not present in the set of columns.
|
||||
|
||||
_**Function type:** Stream and table_
|
||||
|
||||
```js
|
||||
findColumn(
|
||||
fn: (key) => key._field == "fieldName")
|
||||
column: "_value"
|
||||
)
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
### fn
|
||||
A predicate function for matching keys in a table's group key.
|
||||
Expects a `key` argument that represents a group key in the input stream.
|
||||
|
||||
_**Data type:** Function_
|
||||
|
||||
### column
|
||||
Name of the column to extract.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
## Example
|
||||
```js
|
||||
vs = from(bucket:"example-bucket")
|
||||
|> range(start: -5m)
|
||||
|> filter(fn:(r) => r._measurement == "cpu")
|
||||
|> findColumn(
|
||||
fn: (key) => key._field == "usage_idle",
|
||||
column: "_value"
|
||||
)
|
||||
|
||||
// Use column values
|
||||
x = vs[0] + vs[1]
|
||||
```
|
||||
{{< duplicate-oss >}}
|
||||
|
|
|
@ -20,7 +20,7 @@ _**Function type:** Stream and table_
|
|||
|
||||
```js
|
||||
findRecord(
|
||||
fn: (key) => key._field == "fieldName",
|
||||
fn: (key) => key._field == "fieldName"),
|
||||
idx: 0
|
||||
)
|
||||
```
|
||||
|
|
|
@ -14,37 +14,4 @@ related:
|
|||
- /influxdb/cloud/query-data/flux/scalar-values/
|
||||
---
|
||||
|
||||
The `getColumn()` function extracts a column from a table given its label.
|
||||
If the label is not present in the set of columns, the function errors.
|
||||
|
||||
_**Function type:** Stream and table_
|
||||
|
||||
```js
|
||||
getColumn(column: "_value")
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
#### Use tableFind() to extract a single table
|
||||
`getColumn()` requires a single table as input.
|
||||
Use [`tableFind()`](/influxdb/cloud/reference/flux/stdlib/built-in/transformations/stream-table/tablefind/)
|
||||
to extract a single table from a stream of tables.
|
||||
{{% /note %}}
|
||||
|
||||
## Parameters
|
||||
|
||||
### column
|
||||
Name of the column to extract.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
## Example
|
||||
```js
|
||||
vs = from(bucket:"example-bucket")
|
||||
|> range(start: -5m)
|
||||
|> filter(fn:(r) => r._measurement == "cpu")
|
||||
|> tableFind(fn: (key) => key._field == "usage_idle")
|
||||
|> getColumn(column: "_value")
|
||||
|
||||
// Use column values
|
||||
x = vs[0] + vs[1]
|
||||
```
|
||||
{{< duplicate-oss >}}
|
||||
|
|
|
@ -14,37 +14,4 @@ related:
|
|||
- /influxdb/cloud/query-data/flux/scalar-values/
|
||||
---
|
||||
|
||||
The `getRecord()` function extracts a record from a table given the record's index.
|
||||
If the index is out of bounds, the function errors.
|
||||
|
||||
_**Function type:** Stream and table_
|
||||
|
||||
```js
|
||||
getRecord(idx: 0)
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
#### Use tableFind() to extract a single table
|
||||
`getRecord()` requires a single table as input.
|
||||
Use [`tableFind()`](/influxdb/cloud/reference/flux/stdlib/built-in/transformations/stream-table/tablefind/)
|
||||
to extract a single table from a stream of tables.
|
||||
{{% /note %}}
|
||||
|
||||
## Parameters
|
||||
|
||||
### idx
|
||||
Index of the record to extract.
|
||||
|
||||
_**Data type:** Integer_
|
||||
|
||||
## Example
|
||||
```js
|
||||
r0 = from(bucket:"example-bucket")
|
||||
|> range(start: -5m)
|
||||
|> filter(fn:(r) => r._measurement == "cpu")
|
||||
|> tableFind(fn: (key) => key._field == "usage_idle")
|
||||
|> getRecord(idx: 0)
|
||||
|
||||
// Use record values
|
||||
x = r0._field + "--" + r0._measurement
|
||||
```
|
||||
{{< duplicate-oss >}}
|
||||
|
|
|
@ -14,49 +14,4 @@ related:
|
|||
- /influxdb/cloud/query-data/flux/scalar-values/
|
||||
---
|
||||
|
||||
The `tableFind()` function extracts the first table in a stream of tables whose
|
||||
group key values match a predicate. If no table is found, the function errors.
|
||||
|
||||
_**Function type:** Stream and table_
|
||||
|
||||
```js
|
||||
tableFind(fn: (key) => key._field == "fieldName")
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
{{% note %}}
|
||||
Make sure `fn` parameter names match each specified parameter.
|
||||
To learn why, see [Match parameter names](/influxdb/cloud/reference/flux/language/data-model/#match-parameter-names).
|
||||
{{% /note %}}
|
||||
|
||||
### fn
|
||||
|
||||
A predicate function for matching keys in a table's group key.
|
||||
`tableFind` returns the first table that resolves as `true`.
|
||||
Expects a `key` argument that represents a group key in the input stream.
|
||||
|
||||
_**Data type:** Function_
|
||||
|
||||
##### Example fn function
|
||||
|
||||
```js
|
||||
(key) => key._field == "fieldName"
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
t = from(bucket:"example-bucket")
|
||||
|> range(start: -5m)
|
||||
|> filter(fn:(r) => r._measurement == "cpu")
|
||||
|> tableFind(fn: (key) => key._field == "usage_idle")
|
||||
|
||||
// t represents the first table in a stream whose group key
|
||||
// contains "_field" with a value of "usage_idle".
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
You can use `t` from the example above as input for [`getColumn()`](/influxdb/cloud/reference/flux/stdlib/built-in/transformations/stream-table/getcolumn/)
|
||||
and [`getRecord()`](/influxdb/cloud/reference/flux/stdlib/built-in/transformations/stream-table/getrecord/).
|
||||
{{% /note %}}
|
||||
{{< duplicate-oss >}}
|
||||
|
|
|
@ -21,7 +21,7 @@ _**Function type:** Stream and table_
|
|||
|
||||
```js
|
||||
findColumn(
|
||||
fn: (key) => key._field == "fieldName")
|
||||
fn: (key) => key._field == "fieldName"),
|
||||
column: "_value"
|
||||
)
|
||||
```
|
||||
|
|
|
@ -20,7 +20,7 @@ _**Function type:** Stream and table_
|
|||
|
||||
```js
|
||||
findRecord(
|
||||
fn: (key) => key._field == "fieldName",
|
||||
fn: (key) => key._field == "fieldName"),
|
||||
idx: 0
|
||||
)
|
||||
```
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
oss:
|
||||
product: InfluxDB OSS
|
||||
providers:
|
||||
- name: Default
|
||||
regions:
|
||||
- name: localhost:8086
|
||||
url: http://localhost:8086
|
||||
- name: Custom
|
||||
url: http://example.com:8080
|
||||
|
||||
cloud:
|
||||
product: InfluxDB Cloud
|
||||
providers:
|
||||
- name: Amazon Web Services
|
||||
short_name: AWS
|
||||
regions:
|
||||
- name: US West (Oregon)
|
||||
location: Oregon, USA
|
||||
url: https://us-west-2-1.aws.cloud2.influxdata.com
|
||||
- name: US East (Virginia)
|
||||
location: Virginia, USA
|
||||
url: https://us-east-1-1.aws.cloud2.influxdata.com
|
||||
- name: EU Frankfurt
|
||||
location: Frankfurt, Germany
|
||||
url: https://eu-central-1-1.aws.cloud2.influxdata.com
|
||||
- name: Google Cloud Platform
|
||||
short_name: GCP
|
||||
regions:
|
||||
- name: US Central (Iowa)
|
||||
location: Iowa, USA
|
||||
url: https://us-central1-1.gcp.cloud2.influxdata.com
|
||||
- name: Microsoft Azure
|
||||
short_name: Azure
|
||||
regions:
|
||||
- name: West Europe (Amsterdam)
|
||||
location: Amsterdam, Netherlands
|
||||
url: https://westeurope-1.azure.cloud2.influxdata.com
|
||||
- name: East US (Virginia)
|
||||
location: Virginia, USA
|
||||
url: https://eastus-1.azure.cloud2.influxdata.com
|
Loading…
Reference in New Issue