Skip to content
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
11 changes: 11 additions & 0 deletions docs/reference/query-languages/esql/esql-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -818,6 +820,15 @@ FROM employees
| RENAME first_name AS fn, last_name AS ln
```

With multiple `RENAME` commands:

```esql
FROM employees
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the same as the version in docs.csv-spec:104

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will be automating the inclusion of examples soon, so my PR will fix this, making it the same as the example in the csv-spec. If you prefer this two-line RENAME, then edit the example in the csv-spec

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, I see now, this is the third example, and it does not exist at all in rename.csv-spec

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the example

| KEEP first_name, last_name
| RENAME first_name AS fn
| RENAME last_name AS ln
```


## `SORT` [esql-sort]

Expand Down
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
Loading