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
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ The `RENAME` processing command renames one or more columns.
RENAME old_name1 AS new_name1[, ..., old_nameN AS new_nameN]
```

The following syntax is also supported {applies_to}`stack: ga 9.1`:

```esql
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.
::::

**Parameters**

`old_nameX`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,3 +296,50 @@ ROW a="keyword", b=5, c=null
a:integer
5
;

useAssignmentOnly
required_capability: rename_allow_assignment

ROW a = 1, b = "two"
| RENAME aa = a, bb = b
;

aa:integer | bb:keyword
1 | two
;

useAssignmentAndASKeyword
required_capability: rename_allow_assignment

ROW a = 1, b = "two", c = null
| RENAME aa = a, b AS bb, cc = c
;

aa:integer | bb:keyword | cc:null
1 | two | null
;

shadowWithAssignment
required_capability: rename_allow_assignment

ROW a = 1, b = "two"
| RENAME a = b
;

a:keyword
two
;

multipleRenamesWithAssignment
required_capability: rename_sequential_processing
required_capability: rename_allow_assignment

ROW a="keyword", b=5, c=null
| RENAME c = a, a = b
| RENAME b = c
| RENAME b = a, a = b
;

a:integer
5
;
1 change: 1 addition & 0 deletions x-pack/plugin/esql/src/main/antlr/EsqlBaseParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ renameCommand

renameClause:
oldName=qualifiedNamePattern AS newName=qualifiedNamePattern
| newName=qualifiedNamePattern ASSIGN oldName=qualifiedNamePattern
;

dissectCommand
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,11 @@ public enum Cap {
*/
RENAME_SEQUENTIAL_PROCESSING,

/**
* Support for assignment in RENAME, besides the use of `AS` keyword.
*/
RENAME_ALLOW_ASSIGNMENT,

/**
* Support for removing empty attribute in merging output.
* See <a href="https://github.com/elastic/elasticsearch/issues/126392"> ESQL: EVAL after STATS produces an empty column #126392 </a>
Expand Down

Large diffs are not rendered by default.

Loading
Loading