Skip to content

[8.x] ESQL: Updated RENAME docs with the behaviour of multiple column renames #126523

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/reference/esql/processing-commands/rename.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ 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.

*Examples*

[source,esql]
Expand All @@ -40,3 +42,11 @@ Multiple columns can be renamed with a single `RENAME` command:
----
include::{esql-specs}/docs.csv-spec[tag=renameMultipleColumns]
----


With multiple `RENAME` commands:

[source,esql]
----
include::{esql-specs}/docs.csv-spec[tag=renameMultipleColumnsDifferentCommands]
----
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,18 @@ FROM employees
fn:keyword | ln:keyword
;

docsRenameMultipleColumnsDifferentCommands
// tag::renameMultipleColumnsDifferentCommands[]
FROM employees
| KEEP first_name, last_name
| RENAME first_name AS fn
| RENAME last_name AS ln
// end::renameMultipleColumnsDifferentCommands[]
| LIMIT 0;

fn:keyword | ln:keyword
;

docsSort
// tag::sort[]
FROM employees
Expand Down