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 typeReturned value
stringInteger equivalent of the numeric string
bool1 (true) or 0 (false)
durationNumber of nanoseconds in the specified duration
timeEquivalent nanosecond epoch timestamp
floatValue truncated at the decimal
uintInteger 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.