Documentation

schema.fieldsAsCols() function

Flux 0.88.0+

The schema.fieldsAsCols() function is a special application of the pivot() function that pivots on _field and _time columns to aligns fields within each input table that have the same timestamp.

import "influxdata/influxdb/schema"

schema.fieldsAsCols()

Parameters

tables

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

Examples

import "influxdata/influxdb/schema"

from(bucket:"example-bucket")
  |> range(start: -1h)
  |> filter(fn: (r) => r._measurement == "cpu")
  |> schema.fieldsAsCols()

View example input and output

Function definition

package schema

fieldsAsCols = (tables=<-) =>
  tables
    |> pivot(
      rowKey:["_time"],
      columnKey: ["_field"],
      valueColumn: "_value"
    )

Supported in the InfluxDB Cloud UI

The schema package can retrieve schema information from the InfluxDB Cloud user interface (UI), but not from the Flux REPL.


Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.