Documentation

string() function

Flux 0.7.0+

The string() function converts a single value to a string.

Output data type: String

string(v: 123456789)

Parameters

v

Value to convert.

Examples

Convert a boolean to a string value

int(v: true)

// Returns "true"

Convert a duration to a string value

int(v: 1m)

// Returns "1m"

Convert a time to a string value

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

// Returns "2021-01-01T00:00:00Z"

Convert a float to a string value

int(v: 10.12)

// Returns "10.12"

Convert all values in a column to string values

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

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

The following example uses data provided by the sampledata package.

import "sampledata"

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

data
  |> map(fn:(r) => ({ r with foo: string(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.