---
title: rename() function
description: rename() renames columns in a table.
url: https://docs.influxdata.com/flux/v0/stdlib/universe/rename/
estimated_tokens: 2298
product: Flux
version: v0
publisher: InfluxData
canonical: https://docs.influxdata.com/flux/v0/stdlib/universe/rename/
date: '2024-04-08T16:01:02-06:00'
lastmod: '2024-04-08T16:01:02-06:00'
---

* Flux 0.7.0+

InfluxDB support

`rename()` renames columns in a table.

If a column in the group key is renamed, the column name in the group key is updated.

##### Function type signature

```js
(<-tables: stream[B], ?columns: A, ?fn: (column: string) => string) => stream[C] where A: Record, B: Record, C: Record
```

For more information, see [Function type signatures](/flux/v0/function-type-signatures/).

## Parameters

### columns

Record that maps old column names to new column names.

### fn

Function that takes the current column name (`column`) and returns a
new column name.

### tables

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

## Examples

* [Explicitly map column names to new column names](#explicitly-map-column-names-to-new-column-names)
* [Rename columns using a function](#rename-columns-using-a-function)
* [Conditionally rename columns using a function](#conditionally-rename-columns-using-a-function)

### Explicitly map column names to new column names

```js
import "sampledata"

sampledata.int()
    |> rename(columns: {tag: "uid", _value: "val"})
```

[](#view-example-input-and-output)

View example input and output

#### Input data

|       \_time       |\_value|\*tag|
|--------------------|-------|-----|
|2021-01-01T00:00:00Z|  \-2  | t1  |
|2021-01-01T00:00:10Z|  10   | t1  |
|2021-01-01T00:00:20Z|   7   | t1  |
|2021-01-01T00:00:30Z|  17   | t1  |
|2021-01-01T00:00:40Z|  15   | t1  |
|2021-01-01T00:00:50Z|   4   | t1  |

|       \_time       |\_value|\*tag|
|--------------------|-------|-----|
|2021-01-01T00:00:00Z|  19   | t2  |
|2021-01-01T00:00:10Z|   4   | t2  |
|2021-01-01T00:00:20Z|  \-3  | t2  |
|2021-01-01T00:00:30Z|  19   | t2  |
|2021-01-01T00:00:40Z|  13   | t2  |
|2021-01-01T00:00:50Z|   1   | t2  |

#### Output data

|       \_time       |val|\*uid|
|--------------------|---|-----|
|2021-01-01T00:00:00Z|\-2| t1  |
|2021-01-01T00:00:10Z|10 | t1  |
|2021-01-01T00:00:20Z| 7 | t1  |
|2021-01-01T00:00:30Z|17 | t1  |
|2021-01-01T00:00:40Z|15 | t1  |
|2021-01-01T00:00:50Z| 4 | t1  |

|       \_time       |val|\*uid|
|--------------------|---|-----|
|2021-01-01T00:00:00Z|19 | t2  |
|2021-01-01T00:00:10Z| 4 | t2  |
|2021-01-01T00:00:20Z|\-3| t2  |
|2021-01-01T00:00:30Z|19 | t2  |
|2021-01-01T00:00:40Z|13 | t2  |
|2021-01-01T00:00:50Z| 1 | t2  |

### Rename columns using a function

```js
import "sampledata"

sampledata.int()
    |> rename(fn: (column) => "${column}_new")
```

[](#view-example-input-and-output)

View example input and output

#### Input data

|       \_time       |\_value|\*tag|
|--------------------|-------|-----|
|2021-01-01T00:00:00Z|  \-2  | t1  |
|2021-01-01T00:00:10Z|  10   | t1  |
|2021-01-01T00:00:20Z|   7   | t1  |
|2021-01-01T00:00:30Z|  17   | t1  |
|2021-01-01T00:00:40Z|  15   | t1  |
|2021-01-01T00:00:50Z|   4   | t1  |

|       \_time       |\_value|\*tag|
|--------------------|-------|-----|
|2021-01-01T00:00:00Z|  19   | t2  |
|2021-01-01T00:00:10Z|   4   | t2  |
|2021-01-01T00:00:20Z|  \-3  | t2  |
|2021-01-01T00:00:30Z|  19   | t2  |
|2021-01-01T00:00:40Z|  13   | t2  |
|2021-01-01T00:00:50Z|   1   | t2  |

#### Output data

|    \_time\_new     |\_value\_new|\*tag\_new|
|--------------------|------------|----------|
|2021-01-01T00:00:00Z|    \-2     |    t1    |
|2021-01-01T00:00:10Z|     10     |    t1    |
|2021-01-01T00:00:20Z|     7      |    t1    |
|2021-01-01T00:00:30Z|     17     |    t1    |
|2021-01-01T00:00:40Z|     15     |    t1    |
|2021-01-01T00:00:50Z|     4      |    t1    |

|    \_time\_new     |\_value\_new|\*tag\_new|
|--------------------|------------|----------|
|2021-01-01T00:00:00Z|     19     |    t2    |
|2021-01-01T00:00:10Z|     4      |    t2    |
|2021-01-01T00:00:20Z|    \-3     |    t2    |
|2021-01-01T00:00:30Z|     19     |    t2    |
|2021-01-01T00:00:40Z|     13     |    t2    |
|2021-01-01T00:00:50Z|     1      |    t2    |

### Conditionally rename columns using a function

```js
import "sampledata"

sampledata.int()
    |> rename(
        fn: (column) => {
            _newColumnName = if column =~ /^_/ then "${column} (Reserved)" else column

            return _newColumnName
        },
    )
```

[](#view-example-input-and-output)

View example input and output

#### Input data

|       \_time       |\_value|\*tag|
|--------------------|-------|-----|
|2021-01-01T00:00:00Z|  \-2  | t1  |
|2021-01-01T00:00:10Z|  10   | t1  |
|2021-01-01T00:00:20Z|   7   | t1  |
|2021-01-01T00:00:30Z|  17   | t1  |
|2021-01-01T00:00:40Z|  15   | t1  |
|2021-01-01T00:00:50Z|   4   | t1  |

|       \_time       |\_value|\*tag|
|--------------------|-------|-----|
|2021-01-01T00:00:00Z|  19   | t2  |
|2021-01-01T00:00:10Z|   4   | t2  |
|2021-01-01T00:00:20Z|  \-3  | t2  |
|2021-01-01T00:00:30Z|  19   | t2  |
|2021-01-01T00:00:40Z|  13   | t2  |
|2021-01-01T00:00:50Z|   1   | t2  |

#### Output data

| \_time (Reserved)  |\_value (Reserved)|\*tag|
|--------------------|------------------|-----|
|2021-01-01T00:00:00Z|       \-2        | t1  |
|2021-01-01T00:00:10Z|        10        | t1  |
|2021-01-01T00:00:20Z|        7         | t1  |
|2021-01-01T00:00:30Z|        17        | t1  |
|2021-01-01T00:00:40Z|        15        | t1  |
|2021-01-01T00:00:50Z|        4         | t1  |

| \_time (Reserved)  |\_value (Reserved)|\*tag|
|--------------------|------------------|-----|
|2021-01-01T00:00:00Z|        19        | t2  |
|2021-01-01T00:00:10Z|        4         | t2  |
|2021-01-01T00:00:20Z|       \-3        | t2  |
|2021-01-01T00:00:30Z|        19        | t2  |
|2021-01-01T00:00:40Z|        13        | t2  |
|2021-01-01T00:00:50Z|        1         | t2  |

[transformations](/flux/v0/tags/transformations/)
| _time | _value | *tag |
| --- | --- | --- |
| _time | _value | *tag |
| 2021-01-01T00:00:00Z | -2 | t1 |
| 2021-01-01T00:00:10Z | 10 | t1 |
| 2021-01-01T00:00:20Z | 7 | t1 |
| 2021-01-01T00:00:30Z | 17 | t1 |
| 2021-01-01T00:00:40Z | 15 | t1 |
| 2021-01-01T00:00:50Z | 4 | t1 |

| _time | _value | *tag |
| --- | --- | --- |
| _time | _value | *tag |
| 2021-01-01T00:00:00Z | 19 | t2 |
| 2021-01-01T00:00:10Z | 4 | t2 |
| 2021-01-01T00:00:20Z | -3 | t2 |
| 2021-01-01T00:00:30Z | 19 | t2 |
| 2021-01-01T00:00:40Z | 13 | t2 |
| 2021-01-01T00:00:50Z | 1 | t2 |

| _time | val | *uid |
| --- | --- | --- |
| _time | val | *uid |
| 2021-01-01T00:00:00Z | -2 | t1 |
| 2021-01-01T00:00:10Z | 10 | t1 |
| 2021-01-01T00:00:20Z | 7 | t1 |
| 2021-01-01T00:00:30Z | 17 | t1 |
| 2021-01-01T00:00:40Z | 15 | t1 |
| 2021-01-01T00:00:50Z | 4 | t1 |

| _time | val | *uid |
| --- | --- | --- |
| _time | val | *uid |
| 2021-01-01T00:00:00Z | 19 | t2 |
| 2021-01-01T00:00:10Z | 4 | t2 |
| 2021-01-01T00:00:20Z | -3 | t2 |
| 2021-01-01T00:00:30Z | 19 | t2 |
| 2021-01-01T00:00:40Z | 13 | t2 |
| 2021-01-01T00:00:50Z | 1 | t2 |

| _time | _value | *tag |
| --- | --- | --- |
| _time | _value | *tag |
| 2021-01-01T00:00:00Z | -2 | t1 |
| 2021-01-01T00:00:10Z | 10 | t1 |
| 2021-01-01T00:00:20Z | 7 | t1 |
| 2021-01-01T00:00:30Z | 17 | t1 |
| 2021-01-01T00:00:40Z | 15 | t1 |
| 2021-01-01T00:00:50Z | 4 | t1 |

| _time | _value | *tag |
| --- | --- | --- |
| _time | _value | *tag |
| 2021-01-01T00:00:00Z | 19 | t2 |
| 2021-01-01T00:00:10Z | 4 | t2 |
| 2021-01-01T00:00:20Z | -3 | t2 |
| 2021-01-01T00:00:30Z | 19 | t2 |
| 2021-01-01T00:00:40Z | 13 | t2 |
| 2021-01-01T00:00:50Z | 1 | t2 |

| _time_new | _value_new | *tag_new |
| --- | --- | --- |
| _time_new | _value_new | *tag_new |
| 2021-01-01T00:00:00Z | -2 | t1 |
| 2021-01-01T00:00:10Z | 10 | t1 |
| 2021-01-01T00:00:20Z | 7 | t1 |
| 2021-01-01T00:00:30Z | 17 | t1 |
| 2021-01-01T00:00:40Z | 15 | t1 |
| 2021-01-01T00:00:50Z | 4 | t1 |

| _time_new | _value_new | *tag_new |
| --- | --- | --- |
| _time_new | _value_new | *tag_new |
| 2021-01-01T00:00:00Z | 19 | t2 |
| 2021-01-01T00:00:10Z | 4 | t2 |
| 2021-01-01T00:00:20Z | -3 | t2 |
| 2021-01-01T00:00:30Z | 19 | t2 |
| 2021-01-01T00:00:40Z | 13 | t2 |
| 2021-01-01T00:00:50Z | 1 | t2 |

| _time | _value | *tag |
| --- | --- | --- |
| _time | _value | *tag |
| 2021-01-01T00:00:00Z | -2 | t1 |
| 2021-01-01T00:00:10Z | 10 | t1 |
| 2021-01-01T00:00:20Z | 7 | t1 |
| 2021-01-01T00:00:30Z | 17 | t1 |
| 2021-01-01T00:00:40Z | 15 | t1 |
| 2021-01-01T00:00:50Z | 4 | t1 |

| _time | _value | *tag |
| --- | --- | --- |
| _time | _value | *tag |
| 2021-01-01T00:00:00Z | 19 | t2 |
| 2021-01-01T00:00:10Z | 4 | t2 |
| 2021-01-01T00:00:20Z | -3 | t2 |
| 2021-01-01T00:00:30Z | 19 | t2 |
| 2021-01-01T00:00:40Z | 13 | t2 |
| 2021-01-01T00:00:50Z | 1 | t2 |

| _time (Reserved) | _value (Reserved) | *tag |
| --- | --- | --- |
| _time (Reserved) | _value (Reserved) | *tag |
| 2021-01-01T00:00:00Z | -2 | t1 |
| 2021-01-01T00:00:10Z | 10 | t1 |
| 2021-01-01T00:00:20Z | 7 | t1 |
| 2021-01-01T00:00:30Z | 17 | t1 |
| 2021-01-01T00:00:40Z | 15 | t1 |
| 2021-01-01T00:00:50Z | 4 | t1 |

| _time (Reserved) | _value (Reserved) | *tag |
| --- | --- | --- |
| _time (Reserved) | _value (Reserved) | *tag |
| 2021-01-01T00:00:00Z | 19 | t2 |
| 2021-01-01T00:00:10Z | 4 | t2 |
| 2021-01-01T00:00:20Z | -3 | t2 |
| 2021-01-01T00:00:30Z | 19 | t2 |
| 2021-01-01T00:00:40Z | 13 | t2 |
| 2021-01-01T00:00:50Z | 1 | t2 |
