title |
description |
menu |
weight |
aliases |
related |
flux/v0.x/tags |
introduced |
tickscript.select() function |
The `tickscript.select()` function changes a column's name and optionally applies an aggregate or selector function to values in the column.
|
flux_0_x_ref |
name |
parent |
tickscript.select |
tickscript |
|
|
302 |
/influxdb/v2.0/reference/flux/stdlib/contrib/tickscript/select/ |
/influxdb/cloud/reference/flux/stdlib/contrib/tickscript/select/ |
|
/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/selectwindow/ |
/{{< latest "kapacitor" >}}/nodes/query_node/ |
|
|
0.111.0 |
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
.
fn
Aggregate or selector
function to apply.
as
({{< req >}})
New column name.
tables
Input data.
Default is piped-forward data (<-
).
Examples
Change the name of the value column
import "contrib/bonitoo-io/tickscript"
data
|> tickscript.select(as: "example-name")
{{< flex >}}
{{% flex-content %}}
Input data
_time |
_value |
2021-01-01T00:00:00Z |
1.2 |
2021-01-01T01:00:00Z |
3.2 |
2021-01-01T02:00:00Z |
4.0 |
{{% /flex-content %}} |
|
{{% flex-content %}} |
|
Output data
_time |
example-name |
2021-01-01T00:00:00Z |
1.2 |
2021-01-01T01:00:00Z |
3.2 |
2021-01-01T02:00:00Z |
4.0 |
{{% /flex-content %}} |
|
{{< /flex >}} |
|
Change the name of the value column and apply an aggregate function
import "contrib/bonitoo-io/tickscript"
data
|> tickscript.select(as: "sum", fn: sum)
{{< flex >}}
{{% flex-content %}}
Input data
_time |
_value |
2021-01-01T00:00:00Z |
1.2 |
2021-01-01T01:00:00Z |
3.2 |
2021-01-01T02:00:00Z |
4.0 |
{{% /flex-content %}} |
|
{{% flex-content %}} |
|
Output data
sum |
8.4 |
{{% /flex-content %}} |
{{< /flex >}} |
Change the name of the value column and apply a selector function
import "contrib/bonitoo-io/tickscript"
data
|> tickscript.select(as: "max", fn: max)
{{< flex >}}
{{% flex-content %}}
Input data
_time |
_value |
2021-01-01T00:00:00Z |
1.2 |
2021-01-01T01:00:00Z |
3.2 |
2021-01-01T02:00:00Z |
4.0 |
{{% /flex-content %}} |
|
{{% flex-content %}} |
|
Output data
_time |
max |
2021-01-01T02:00:00Z |
4.0 |
{{% /flex-content %}} |
|
{{< /flex >}} |
|