Back to Influxdb

toBool() function

content/flux/v0/stdlib/universe/tobool.md

latest2.8 KB
Original Source
<!------------------------------------------------------------------------------ IMPORTANT: This page was generated from comments in the Flux source code. Any edits made directly to this page will be overwritten the next time the documentation is generated. To make updates to this documentation, update the function comments above the function definition in the Flux source code: https://github.com/influxdata/flux/blob/master/stdlib/universe/universe.flux#L4778-L4778 Contributing to Flux: https://github.com/influxdata/flux#contributing Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md ------------------------------------------------------------------------------->

toBool() converts all values in the _value column to boolean types.

Supported data types

  • string: true or false
  • int: 1 or 0
  • uint: 1 or 0
  • float: 1.0 or 0.0
Function type signature
js
(<-tables: stream[{A with _value: B}]) => stream[{A with _value: B, _value: bool}]

{{% caption %}} For more information, see Function type signatures. {{% /caption %}}

Parameters

tables

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

Examples

Convert an integer _value column to booleans

js
import "sampledata"

sampledata.numericBool()
    |> toBool()

{{< expand-wrapper >}} {{% expand "View example input and output" %}}

Input data

_time_value*tag
2021-01-01T00:00:00Z1t1
2021-01-01T00:00:10Z1t1
2021-01-01T00:00:20Z0t1
2021-01-01T00:00:30Z1t1
2021-01-01T00:00:40Z0t1
2021-01-01T00:00:50Z0t1
_time_value*tag
2021-01-01T00:00:00Z0t2
2021-01-01T00:00:10Z1t2
2021-01-01T00:00:20Z0t2
2021-01-01T00:00:30Z1t2
2021-01-01T00:00:40Z1t2
2021-01-01T00:00:50Z0t2

Output data

_time_value*tag
2021-01-01T00:00:00Ztruet1
2021-01-01T00:00:10Ztruet1
2021-01-01T00:00:20Zfalset1
2021-01-01T00:00:30Ztruet1
2021-01-01T00:00:40Zfalset1
2021-01-01T00:00:50Zfalset1
_time_value*tag
2021-01-01T00:00:00Zfalset2
2021-01-01T00:00:10Ztruet2
2021-01-01T00:00:20Zfalset2
2021-01-01T00:00:30Ztruet2
2021-01-01T00:00:40Ztruet2
2021-01-01T00:00:50Zfalset2

{{% /expand %}} {{< /expand-wrapper >}}