1.5 KiB
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. |
|
|
102 |
|
|
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}