Documentation

tickscript.select() function

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

The tickscript.select() function changes a column’s name and optionally applies an aggregate or selector function to values in the column.

import "contrib/bonitoo-io/tickscript"

tickscript.select(
  column: "_value",
  fn: sum,
  as: "example-name"
)

TICKscript helper function

tickscript.select() is a helper function meant to replicate TICKscript operations like the following:

// Rename
query("SELECT x AS y")

// Aggregate and rename
query("SELECT f(x) AS y")

Parameters

column

Column to operate on. Default is _value.

Data type: String

fn

Aggregate or selector function to apply.

Data type: Function

as

(Required) New column name.

Data type: String

Examples


Change the name of the value column

import "contrib/bonitoo-io/tickscript"

data
  |> tickscript.select(as: "example-name")
Input data
_time_value
2021-01-01T00:00:00Z1.2
2021-01-01T01:00:00Z3.2
2021-01-01T02:00:00Z4.0
Output data
_timeexample-name
2021-01-01T00:00:00Z1.2
2021-01-01T01:00:00Z3.2
2021-01-01T02:00:00Z4.0

Change the name of the value column and apply an aggregate function

import "contrib/bonitoo-io/tickscript"

data
  |> tickscript.select(
    as: "sum",
    fn: sum
  )
Input data
_time_value
2021-01-01T00:00:00Z1.2
2021-01-01T01:00:00Z3.2
2021-01-01T02:00:00Z4.0
Output data
sum
8.4

Change the name of the value column and apply a selector function

import "contrib/bonitoo-io/tickscript"

data
  |> tickscript.select(
    as: "max",
    fn: max
  )
Input data
_time_value
2021-01-01T00:00:00Z1.2
2021-01-01T01:00:00Z3.2
2021-01-01T02:00:00Z4.0
Output data
_timemax
2021-01-01T02:00:00Z4.0

Package author and maintainer

Github: @bonitoo-io, @alespour
InfluxDB Slack: @Ales Pour


Cloud or OSS?

InfluxDB OSS 2.0 now generally available!

InfluxDB OSS 2.0 is now generally available and ready for production use. See the InfluxDB OSS 2.0 release notes.

For information about upgrading to InfluxDB OSS 2.0, see: