Skip to content

Commit 90dcccf

Browse files
authored
ESQL: Updated RENAME docs with the behaviour of multiple column renames (#126462)
* ESQL: Updated RENAME docs with the behaviour of multiple column renames * Added rename example to csv-spec
1 parent 4129768 commit 90dcccf

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

docs/reference/query-languages/esql/esql-commands.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,8 @@ RENAME old_name1 AS new_name1[, ..., old_nameN AS new_nameN]
802802

803803
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.
804804

805+
A `RENAME` with multiple column renames is equivalent to multiple sequential `RENAME` commands.
806+
805807
**Examples**
806808

807809
```esql
@@ -818,6 +820,15 @@ FROM employees
818820
| RENAME first_name AS fn, last_name AS ln
819821
```
820822

823+
With multiple `RENAME` commands:
824+
825+
```esql
826+
FROM employees
827+
| KEEP first_name, last_name
828+
| RENAME first_name AS fn
829+
| RENAME last_name AS ln
830+
```
831+
821832

822833
## `SORT` [esql-sort]
823834

x-pack/plugin/esql/qa/testFixtures/src/main/resources/docs.csv-spec

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,18 @@ FROM employees
112112
fn:keyword | ln:keyword
113113
;
114114

115+
docsRenameMultipleColumnsDifferentCommands
116+
// tag::renameMultipleColumnsDifferentCommands[]
117+
FROM employees
118+
| KEEP first_name, last_name
119+
| RENAME first_name AS fn
120+
| RENAME last_name AS ln
121+
// end::renameMultipleColumnsDifferentCommands[]
122+
| LIMIT 0;
123+
124+
fn:keyword | ln:keyword
125+
;
126+
115127
docsSort
116128
// tag::sort[]
117129
FROM employees

0 commit comments

Comments
 (0)