From fba827d8b4a9b03b52f0baf82aa278946b37f70f Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Thu, 17 Dec 2020 09:18:35 -0700 Subject: [PATCH] hotfix: fixed stream and table function examples --- .../transformations/stream-table/_index.md | 39 +-------------- .../stream-table/findcolumn.md | 41 +--------------- .../stream-table/findrecord.md | 2 +- .../transformations/stream-table/getcolumn.md | 35 +------------- .../transformations/stream-table/getrecord.md | 35 +------------- .../transformations/stream-table/tablefind.md | 47 +------------------ .../stream-table/findcolumn.md | 2 +- .../stream-table/findrecord.md | 2 +- data/influxdb_urls.yml | 40 ---------------- 9 files changed, 8 insertions(+), 235 deletions(-) delete mode 100644 data/influxdb_urls.yml diff --git a/content/influxdb/cloud/reference/flux/stdlib/built-in/transformations/stream-table/_index.md b/content/influxdb/cloud/reference/flux/stdlib/built-in/transformations/stream-table/_index.md index 3cd22a890..baefee1b7 100644 --- a/content/influxdb/cloud/reference/flux/stdlib/built-in/transformations/stream-table/_index.md +++ b/content/influxdb/cloud/reference/flux/stdlib/built-in/transformations/stream-table/_index.md @@ -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 >}} diff --git a/content/influxdb/cloud/reference/flux/stdlib/built-in/transformations/stream-table/findcolumn.md b/content/influxdb/cloud/reference/flux/stdlib/built-in/transformations/stream-table/findcolumn.md index 33c5f7738..5df8a690a 100644 --- a/content/influxdb/cloud/reference/flux/stdlib/built-in/transformations/stream-table/findcolumn.md +++ b/content/influxdb/cloud/reference/flux/stdlib/built-in/transformations/stream-table/findcolumn.md @@ -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 >}} diff --git a/content/influxdb/cloud/reference/flux/stdlib/built-in/transformations/stream-table/findrecord.md b/content/influxdb/cloud/reference/flux/stdlib/built-in/transformations/stream-table/findrecord.md index 86794c9e3..0a0618ad1 100644 --- a/content/influxdb/cloud/reference/flux/stdlib/built-in/transformations/stream-table/findrecord.md +++ b/content/influxdb/cloud/reference/flux/stdlib/built-in/transformations/stream-table/findrecord.md @@ -20,7 +20,7 @@ _**Function type:** Stream and table_ ```js findRecord( - fn: (key) => key._field == "fieldName", + fn: (key) => key._field == "fieldName"), idx: 0 ) ``` diff --git a/content/influxdb/cloud/reference/flux/stdlib/built-in/transformations/stream-table/getcolumn.md b/content/influxdb/cloud/reference/flux/stdlib/built-in/transformations/stream-table/getcolumn.md index 8bbfd2785..33e063809 100644 --- a/content/influxdb/cloud/reference/flux/stdlib/built-in/transformations/stream-table/getcolumn.md +++ b/content/influxdb/cloud/reference/flux/stdlib/built-in/transformations/stream-table/getcolumn.md @@ -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 >}} diff --git a/content/influxdb/cloud/reference/flux/stdlib/built-in/transformations/stream-table/getrecord.md b/content/influxdb/cloud/reference/flux/stdlib/built-in/transformations/stream-table/getrecord.md index 10bdd9be5..a479b8fbb 100644 --- a/content/influxdb/cloud/reference/flux/stdlib/built-in/transformations/stream-table/getrecord.md +++ b/content/influxdb/cloud/reference/flux/stdlib/built-in/transformations/stream-table/getrecord.md @@ -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 >}} diff --git a/content/influxdb/cloud/reference/flux/stdlib/built-in/transformations/stream-table/tablefind.md b/content/influxdb/cloud/reference/flux/stdlib/built-in/transformations/stream-table/tablefind.md index 56eb08a7e..dbeaa2b71 100644 --- a/content/influxdb/cloud/reference/flux/stdlib/built-in/transformations/stream-table/tablefind.md +++ b/content/influxdb/cloud/reference/flux/stdlib/built-in/transformations/stream-table/tablefind.md @@ -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 >}} diff --git a/content/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/findcolumn.md b/content/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/findcolumn.md index 7999a56f0..4fdbd34f1 100644 --- a/content/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/findcolumn.md +++ b/content/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/findcolumn.md @@ -21,7 +21,7 @@ _**Function type:** Stream and table_ ```js findColumn( - fn: (key) => key._field == "fieldName") + fn: (key) => key._field == "fieldName"), column: "_value" ) ``` diff --git a/content/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/findrecord.md b/content/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/findrecord.md index ac1d045c2..bb83517a8 100644 --- a/content/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/findrecord.md +++ b/content/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/findrecord.md @@ -20,7 +20,7 @@ _**Function type:** Stream and table_ ```js findRecord( - fn: (key) => key._field == "fieldName", + fn: (key) => key._field == "fieldName"), idx: 0 ) ``` diff --git a/data/influxdb_urls.yml b/data/influxdb_urls.yml deleted file mode 100644 index f1d21f519..000000000 --- a/data/influxdb_urls.yml +++ /dev/null @@ -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