> For the complete documentation index, see [llms.txt](https://docs.scanner.dev/scanner/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.scanner.dev/scanner/using-scanner-complete-feature-reference/querying-and-analysis/aggregation-functions/rename.md).

# 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 foo` will first rename `col1` as `foo`, then rename `col2` as `foo` . `foo` will contain the values of `col2` ; the values of `col1` will not exist in the output.
* `rename col1 as foo, foo as bar` will rename `col1` as `foo`, then rename `foo` as `bar`. `bar` will contain the values of `col1`; `foo` will 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.

```python
* | rename elapsed_ms as Latency
```

Rename a column to a name with spaces.

```python
* | rename elapsed_ms as "Latency in milliseconds"
```

Rename multiple columns.

```python
* | rename elapsed_ms as Latency, hostname as Host
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.scanner.dev/scanner/using-scanner-complete-feature-reference/querying-and-analysis/aggregation-functions/rename.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
