Documentation

tickscript.selectWindow() function

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

The tickscript.selectWindow() function changes a column’s name, windows rows by time, and applies an aggregate or selector function the specified column for each window of time.

import "contrib/bonitoo-io/tickscript"

tickscript.selectWindow(
  column: "_value",
  fn: sum,
  as: "example-name",
  every: 1m,
  defaultValue: 0.0,
)

TICKscript helper function

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

// Rename, window, and aggregate
query("SELECT f(x) AS y")
  .groupBy(time(t), ...)

Parameters

column

Column to operate on. Default is _value.

Data type: String

fn

(Required) Aggregate or selector function to apply.

Data type: Function

as

(Required) New column name.

Data type: String

every

(Required) Duration of windows.

Data type: Duration

defaultValue

(Required) Default fill value for null values in column.

Must be the same data type as column.

Data type: String | Boolean | Float | Integer | Uinteger | Bytes

Examples

Change the name of, window, and then aggregate the value column

import "contrib/bonitoo-io/tickscript"

data
  |> tickscript.selectWindow(
    fn: sum,
    as: "example-name",
    every: 1h,
    defaultValue: 0.0
  )
Input data
_time_value
2021-01-01T00:00:00Z1.2
2021-01-01T00:30:00Z0.8
2021-01-01T01:00:00Z3.2
2021-01-01T01:30:00Z3.9
2021-01-01T02:00:00Z
2021-01-01T02:30:00Z3.3
Output data
_timeexample-name
2021-01-01T00:59:592.0
2021-01-01T01:59:597.1
2021-01-01T02:59:593.3

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: