Documentation

toInt() function

Flux 0.7.0+

The toInt() function converts all values in the _value column to integers.

toInt()
Supported data types
  • bool
  • duration
  • float
  • string (numeric)
  • time
  • uinteger

toInt() behavior depends on the _value column data type:

_value type Returned value
string Integer equivalent of the numeric string
bool 1 (true) or 0 (false)
duration Number of nanoseconds in the specified duration
time Equivalent nanosecond epoch timestamp
float Value truncated at the decimal
uint Integer equivalent of the unsigned integer

To convert values in a column other than _value, define a custom function patterned after the function definition, but replace _value with your desired column.

Parameters

tables

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

Examples

The following examples use data provided by the sampledata package to show how toInt() transforms data.

Convert a float value column to an integer column

import "sampledata"

sampledata.float()
  |> toInt()

View input and output

Convert a boolean value column to an integer column

import "sampledata"

sampledata.bool()
  |> toInt()

View input and output

Convert a uinteger value column to an integer column

import "sampledata"

sampledata.uint()
  |> toInt()

View input and output

Function definition

toInt = (tables=<-) =>
  tables
    |> map(fn:(r) => ({ r with _value: int(v: r._value) }))

Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.