diff --git a/docs/reference/query-languages/esql/esql-commands.md b/docs/reference/query-languages/esql/esql-commands.md index 0da0d1c5c9a88..0e2b679d0f101 100644 --- a/docs/reference/query-languages/esql/esql-commands.md +++ b/docs/reference/query-languages/esql/esql-commands.md @@ -802,6 +802,8 @@ RENAME old_name1 AS new_name1[, ..., old_nameN AS new_nameN] 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** ```esql @@ -818,6 +820,15 @@ FROM employees | RENAME first_name AS fn, last_name AS ln ``` +With multiple `RENAME` commands: + +```esql +FROM employees +| KEEP first_name, last_name +| RENAME first_name AS fn +| RENAME last_name AS ln +``` + ## `SORT` [esql-sort] diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/docs.csv-spec b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/docs.csv-spec index aa89c775da4cf..2207bb1ce3a09 100644 --- a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/docs.csv-spec +++ b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/docs.csv-spec @@ -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