3.0 KiB
3.0 KiB
| title | description | menu | weight | flux/v0/tags | deprecated | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| v1.fieldsAsCols() function | `v1.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 |
|
0.88.0 |
v1.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.
{{% warn %}}
Deprecated
See influxdata/influxdata/schema.fieldsAsCols. {{% /warn %}}
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/v1"
data
|> v1.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 >}}