Documentation

aggregate.table() function

aggregate.table() is a user-contributed function maintained by the package author and can be updated or removed at any time.

aggregate.table() will aggregate columns and create tables with a single row containing the aggregated value.

Function type signature
(<-tables: stream[B], columns: A) => stream[C] where A: Record, B: Record, C: Record
For more information, see Function type signatures.

Parameters

tables

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

columns

(Required) Columns to aggregate and which aggregate method to use.

Columns is a record where the key is a column name and the value is an aggregate record. The aggregate record is composed of at least the following required attributes:

  • column: Input column name (string).
  • init: A function to compute the initial state of the output. This can return either the final aggregate or a temporary state object that can be used to compute the final aggregate. The values parameter will always be a non-empty array of values from the specified column. For example: (values) => state.
  • reduce: A function that takes in another buffer of values and the current state of the aggregate and computes the updated state. For example: (values, state) => state.
  • compute: A function that takes the state and computes the final aggregate. For example, (state) => value.
  • fill: The value passed to fill(). If present, the fill value determines what the aggregate does when there are no values. This can either be a value or one of the predefined identifiers of null or none. This value must be the same type as the value return from compute.

Examples

Compute the min of a specific column

import "sampledata"
import "contrib/jsternberg/aggregate"

sampledata.float()
    |> aggregate.table(columns: {"min_bottom_degrees": aggregate.min(column: "_value")})

View example input and ouput


Was this page helpful?

Thank you for your feedback!


Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.