Skip to content

[8.19] ESQL: Extend RENAME syntax to allow a new = old syntax (#129212) #129254

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 2 commits into from
Jun 11, 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
9 changes: 9 additions & 0 deletions docs/reference/esql/processing-commands/rename.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ 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:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@leemthompo, I guess not tagging a specific version is OK here, since we have per-branch docs in 8.x?


[source,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 @@ -269,6 +269,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 @@ -307,6 +307,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"> EVAL after STATS produces an empty column #126392 </a>
Expand Down

Large diffs are not rendered by default.

Loading