Back to Influxdb

toUInt() function

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

latest7.3 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#L4716-L4716 Contributing to Flux: https://github.com/influxdata/flux#contributing Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md ------------------------------------------------------------------------------->

toUInt() converts all values in the _value column to unsigned integer types.

Supported types and behaviors

toUInt() behavior depends on the _value column type:

_value typeReturned value
stringUInteger 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
intUInteger equivalent of the integer
Function type signature
js
(<-tables: stream[{A with _value: B}]) => stream[{A with _value: B, _value: uint}]

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

Parameters

tables

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

Examples

Convert a float _value column to uintegers

js
import "sampledata"

sampledata.float()
    |> toUInt()

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

Input data

_time*tag_value
2021-01-01T00:00:00Zt1-2.18
2021-01-01T00:00:10Zt110.92
2021-01-01T00:00:20Zt17.35
2021-01-01T00:00:30Zt117.53
2021-01-01T00:00:40Zt115.23
2021-01-01T00:00:50Zt14.43
_time*tag_value
2021-01-01T00:00:00Zt219.85
2021-01-01T00:00:10Zt24.97
2021-01-01T00:00:20Zt2-3.75
2021-01-01T00:00:30Zt219.77
2021-01-01T00:00:40Zt213.86
2021-01-01T00:00:50Zt21.86

Output data

_time_value*tag
2021-01-01T00:00:00Z18446744073709551614t1
2021-01-01T00:00:10Z10t1
2021-01-01T00:00:20Z7t1
2021-01-01T00:00:30Z17t1
2021-01-01T00:00:40Z15t1
2021-01-01T00:00:50Z4t1
_time_value*tag
2021-01-01T00:00:00Z19t2
2021-01-01T00:00:10Z4t2
2021-01-01T00:00:20Z18446744073709551613t2
2021-01-01T00:00:30Z19t2
2021-01-01T00:00:40Z13t2
2021-01-01T00:00:50Z1t2

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

Convert a boolean _value column to uintegers

js
import "sampledata"

sampledata.bool()
    |> toUInt()

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

Input data

_time*tag_value
2021-01-01T00:00:00Zt1true
2021-01-01T00:00:10Zt1true
2021-01-01T00:00:20Zt1false
2021-01-01T00:00:30Zt1true
2021-01-01T00:00:40Zt1false
2021-01-01T00:00:50Zt1false
_time*tag_value
2021-01-01T00:00:00Zt2false
2021-01-01T00:00:10Zt2true
2021-01-01T00:00:20Zt2false
2021-01-01T00:00:30Zt2true
2021-01-01T00:00:40Zt2true
2021-01-01T00:00:50Zt2false

Output 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

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

Convert a uinteger _value column to an uintegers

js
import "sampledata"

sampledata.uint()
    |> toUInt()

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

Input data

_time_value*tag
2021-01-01T00:00:00Z18446744073709551614t1
2021-01-01T00:00:10Z10t1
2021-01-01T00:00:20Z7t1
2021-01-01T00:00:30Z17t1
2021-01-01T00:00:40Z15t1
2021-01-01T00:00:50Z4t1
_time_value*tag
2021-01-01T00:00:00Z19t2
2021-01-01T00:00:10Z4t2
2021-01-01T00:00:20Z18446744073709551613t2
2021-01-01T00:00:30Z19t2
2021-01-01T00:00:40Z13t2
2021-01-01T00:00:50Z1t2

Output data

_time_value*tag
2021-01-01T00:00:00Z18446744073709551614t1
2021-01-01T00:00:10Z10t1
2021-01-01T00:00:20Z7t1
2021-01-01T00:00:30Z17t1
2021-01-01T00:00:40Z15t1
2021-01-01T00:00:50Z4t1
_time_value*tag
2021-01-01T00:00:00Z19t2
2021-01-01T00:00:10Z4t2
2021-01-01T00:00:20Z18446744073709551613t2
2021-01-01T00:00:30Z19t2
2021-01-01T00:00:40Z13t2
2021-01-01T00:00:50Z1t2

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