rename() function
The rename()
function renames specified columns in a table.
If a column is renamed and is part of the group key, the column name in the group key will be updated.
There are two variants:
- one which maps old column names to new column names
- one which takes a mapping function.
rename(columns: {host: "server", facility: "datacenter"})
// OR
rename(fn: (column) => "{column}_new")
Parameters
Make sure fn
parameter names match each specified parameter. To learn why, see Match parameter names.
columns
A map of columns to rename and their corresponding new names.
Cannot be used with fn
.
fn
A function mapping between old and new column names.
Cannot be used with columns
.
tables
Input data.
Default is piped-forward data (<-
).
Examples
The following examples use data provided by the sampledata
package
to show how rename()
transforms data.
Rename specific columns
import "sampledata"
sampledata.int()
|> rename(columns: {tag: "uid", _value: "val"})
Rename all columns using a function
import "sampledata"
sampledata.int()
|> rename(fn: (column) => "${column}_new")
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.