rename()
rename(col as alias [, ...col as alias]) renames one or more columns in the input stream.
alias can be one word or include spaces. Aliases with spaces must be enclosed in quotation marks. If alias is the name of an existing column, rename will overwrite its values with the values of col.
Columns are renamed in order:
rename col1 as foo, col2 as foowill first renamecol1asfoo, then renamecol2asfoo.foowill contain the values ofcol2; the values ofcol1will not exist in the output.rename col1 as foo, foo as barwill renamecol1asfoo, then renamefooasbar.barwill be contain the values ofcol1;foowill not exist.
rename has no effect if col and alias do not exist. If col does not exist and alias is the name of an existing column, alias will not exist.
A column cannot have multiple aliases, e.g. rename col1 as foo, col1 as bar is not valid.
Returns
The same table as the input with specified columns renamed to aliases. If a column was renamed, the original column name does not exist in the output.
Examples
# Rename a column
* | rename elapsed_ms as Latency
# Rename a column to a name with spaces
* | rename elapsed_ms as "Latency in milliseconds"
# Rename multiple columns
* | rename elapsed_ms as Latency, hostname as HostLast updated
Was this helpful?