string() function
The string()
function converts a single value to a string.
string(v: 123456789)
Parameters
v
Value to convert.
Examples
- Convert a boolean to a string value
- Convert a duration to a string value
- Convert a time to a string value
- Convert a float to a string value
- Convert all values in a column to string values
Convert a boolean to a string value
string(v: true)
// Returns "true"
Convert a duration to a string value
string(v: 1m)
// Returns "1m"
Convert a time to a string value
string(v: 2021-01-01T00:00:00Z)
// Returns "2021-01-01T00:00:00Z"
Convert a float to a string value
string(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
:
- Use
map()
to iterate over and update all input rows. - 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)}))
Was this page helpful?
Thank you for your feedback!
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for Flux and this documentation. To find support, use the following resources:
InfluxDB Cloud customers can contact InfluxData Support.