docs-v2/content/flux/v0.x/stdlib/universe/getrecord.md

1.5 KiB

title description aliases menu weight flux/v0.x/tags related introduced
getRecord() function The `getRecord()` function extracts a record from a table given its index. If the index is out of bounds, the function errors.
/influxdb/v2.0/reference/flux/functions/built-in/transformations/stream-table/getrecord/
/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/getrecord/
/influxdb/cloud/reference/flux/stdlib/built-in/transformations/stream-table/getrecord/
flux_0_x_ref
name parent
getRecord universe
102
dynamic queries
/{{< latest "influxdb" >}}/query-data/flux/scalar-values/
0.29.0

The getRecord() function extracts a record from a table given the record's index. If the index is out of bounds, the function errors.

getRecord(idx: 0)

{{% note %}}

Use tableFind() to extract a single table

getRecord() requires a single table as input. Use tableFind() to extract a single table from a stream of tables. {{% /note %}}

Parameters

idx

Index of the record to extract.

table

Input table. Default is piped-forward data (<-).

Example

{{% flux/sample-example-intro %}}

import "sampledata"

sampledata.int()
    |> tableFind(fn: (key) => key.tag == "t1")
    |> getRecord(idx: 0)
    
// Returns {_time: 2021-01-01T00:00:00.000000000Z, _value: -2, tag: t1}