Documentation

uint() function

Flux 0.7.0+

The uint() function converts a single value to a UInteger.

Output data type: UInteger

uint(v: "4")

Parameters

v

The value to convert.

uint() behavior depends on the input data type:

Input type Returned value
bool 1 (true) or 0 (false)
duration Number of nanoseconds in the specified duration
float UInteger equivalent of the float value truncated at the decimal
int UInteger equivalent of the integer
string UInteger equivalent of the numeric string
time Equivalent nanosecond epoch timestamp

Examples

Convert a string to a uinteger value

uint(v: "3")

// Returns 3 (uint)

Convert a boolean to a uinteger value

uint(v: true)

// Returns 1

Convert a duration to a uinteger value

uint(v: 1m)

// Returns 160000000000

Convert a time to a uinteger value

uint(v: 2021-01-01T00:00:00Z)

// Returns 1609459200000000000

Convert a float to a uinteger value

uint(v: 10.12)

// Returns 10

Convert all values in a column to uinteger values

If updating values in the _value column, use toUInt(). To update values in columns other than _value:

  1. Use map() to iterate over and update all input rows.
  2. Use uint() to update the value of a column.

The following example uses data provided by the sampledata package.

import "sampledata"

data = sampledata.float()
  |> rename(columns: {_value: "foo"})

data
  |> map(fn:(r) => ({ r with foo: uint(v: r.foo) }))

View input and output


Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.