Type to search.

ES|QL RENAME command

Serverless

Elastic Cloud Serverless projects are autoscaled environments, fully managed by Elastic and available on Elastic Cloud.

Availability

  • Generally available

    This functionality is generally available and ready for production usage.

Serverless interfaces and procedures might differ from classic Elastic Stack deployments.

Stack

The Elastic Stack includes Elastic's core products such as Elasticsearch, Kibana, Logstash, and Beats.

Availability

  • Generally available

    This functionality is generally available and ready for production usage.

Unless stated otherwise on the page, this functionality is available when your Elastic Stack is deployed on Elastic Cloud Hosted, Elastic Cloud Enterprise, Elastic Cloud on Kubernetes, and self-managed environments.

This documentation corresponds to the latest patch available for each minor version. If you're not using the latest patch, check the release notes for changes.

The RENAME processing command renames one or more columns.

ES|QL
RENAME old_name1 AS new_name1[, ..., old_nameN AS new_nameN]

The following syntax is also supported The Elastic Stack includes Elastic's core products such as Elasticsearch, Kibana, Logstash, and Beats. Availability Generally available since 9.1 This functionality is generally available and ready for production usage. Unless stated otherwise on the page, this functionality is available when your Elastic Stack is deployed on Elastic Cloud Hosted, Elastic Cloud Enterprise, Elastic Cloud on Kubernetes, and self-managed environments. This documentation corresponds to the latest patch available for each minor version. If you're not using the latest patch, check the release notes for changes. :

ES|QL
RENAME new_name1 = old_name1[, ..., new_nameN = old_nameN]
Tip

Both syntax options can be used interchangeably but we recommend sticking to one for consistency and readability.

old_nameX
The name of a column you want to rename.
new_nameX
The new name of the column. If it conflicts with an existing column name, the existing column is dropped. If multiple columns are renamed to the same name, all but the rightmost column with the same new name are dropped.

The RENAME processing command renames one or more columns. If a column with the new name already exists, it will be replaced by the new column.

A RENAME with multiple column renames is equivalent to multiple sequential RENAME commands.

ES|QL
FROM employees
| KEEP first_name, last_name, still_hired
| RENAME  still_hired AS employed
ES|QL
FROM employees
| KEEP first_name, last_name
| RENAME first_name AS fn, last_name AS ln

The same result can be achieved with multiple RENAME commands:

ES|QL
FROM employees
| KEEP first_name, last_name
| RENAME first_name AS fn
| RENAME last_name AS ln