2.9 KiB
2.9 KiB
title | description | menu | weight | flux/v0/tags | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
schema.fieldsAsCols() function | `schema.fieldsAsCols()` is a special application of `pivot()` that pivots input data on `_field` and `_time` columns to align fields within each input table that have the same timestamp. |
|
301 |
|
schema.fieldsAsCols()
is a special application of pivot()
that pivots input data
on _field
and _time
columns to align fields within each input table that
have the same timestamp.
Function type signature
(<-tables: stream[A]) => stream[B] where A: Record, B: Record
{{% caption %}} For more information, see Function type signatures. {{% /caption %}}
Parameters
tables
Input data. Default is piped-forward data (<-
).
Examples
Pivot InfluxDB fields into columns
import "influxdata/influxdb/schema"
data
|> schema.fieldsAsCols()
{{< expand-wrapper >}} {{% expand "View example input and output" %}}
Input data
_time | *_measurement | *loc | *_field | _value |
---|---|---|---|---|
2021-01-01T12:00:00Z | m | Seattle | hum | 89.2 |
2021-01-02T12:00:00Z | m | Seattle | hum | 90.5 |
2021-01-03T12:00:00Z | m | Seattle | hum | 81.0 |
_time | *_measurement | *loc | *_field | _value |
---|---|---|---|---|
2021-01-01T12:00:00Z | m | Seattle | temp | 73.1 |
2021-01-02T12:00:00Z | m | Seattle | temp | 68.2 |
2021-01-03T12:00:00Z | m | Seattle | temp | 61.4 |
Output data
_time | *_measurement | *loc | hum | temp |
---|---|---|---|---|
2021-01-01T12:00:00Z | m | Seattle | 89.2 | 73.1 |
2021-01-02T12:00:00Z | m | Seattle | 90.5 | 68.2 |
2021-01-03T12:00:00Z | m | Seattle | 81.0 | 61.4 |
{{% /expand %}} {{< /expand-wrapper >}}