Skip to content

Commit 1105bf9

Browse files
authored
Merge branch 'main' into revert-128293
2 parents f91da12 + 6c7730d commit 1105bf9

File tree

14 files changed

+834
-745
lines changed

14 files changed

+834
-745
lines changed

docs/reference/query-languages/esql/_snippets/commands/layout/rename.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ The `RENAME` processing command renames one or more columns.
88
RENAME old_name1 AS new_name1[, ..., old_nameN AS new_nameN]
99
```
1010

11+
The following syntax is also supported {applies_to}`stack: ga 9.1`:
12+
13+
```esql
14+
RENAME new_name1 = old_name1[, ..., new_nameN = old_nameN]
15+
```
16+
17+
::::{tip}
18+
Both syntax options can be used interchangeably but we recommend sticking to one for consistency and readability.
19+
::::
20+
1121
**Parameters**
1222

1323
`old_nameX`

muted-tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,9 @@ tests:
517517
- class: org.elasticsearch.xpack.esql.qa.single_node.GenerativeForkIT
518518
method: test {lookup-join.EnrichLookupStatsBug SYNC}
519519
issue: https://github.com/elastic/elasticsearch/issues/129229
520+
- class: org.elasticsearch.xpack.esql.qa.single_node.GenerativeForkIT
521+
method: test {lookup-join.MultipleBatches*
522+
issue: https://github.com/elastic/elasticsearch/issues/129210
520523

521524
# Examples:
522525
#

x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/RestSampleTestCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class RestSampleTestCase extends ESRestTestCase {
3333
public void skipWhenSampleDisabled() throws IOException {
3434
assumeTrue(
3535
"Requires SAMPLE capability",
36-
EsqlSpecTestCase.hasCapabilities(adminClient(), List.of(EsqlCapabilities.Cap.SAMPLE.capabilityName()))
36+
EsqlSpecTestCase.hasCapabilities(adminClient(), List.of(EsqlCapabilities.Cap.SAMPLE_V2.capabilityName()))
3737
);
3838
}
3939

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

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,3 +296,50 @@ ROW a="keyword", b=5, c=null
296296
a:integer
297297
5
298298
;
299+
300+
useAssignmentOnly
301+
required_capability: rename_allow_assignment
302+
303+
ROW a = 1, b = "two"
304+
| RENAME aa = a, bb = b
305+
;
306+
307+
aa:integer | bb:keyword
308+
1 | two
309+
;
310+
311+
useAssignmentAndASKeyword
312+
required_capability: rename_allow_assignment
313+
314+
ROW a = 1, b = "two", c = null
315+
| RENAME aa = a, b AS bb, cc = c
316+
;
317+
318+
aa:integer | bb:keyword | cc:null
319+
1 | two | null
320+
;
321+
322+
shadowWithAssignment
323+
required_capability: rename_allow_assignment
324+
325+
ROW a = 1, b = "two"
326+
| RENAME a = b
327+
;
328+
329+
a:keyword
330+
two
331+
;
332+
333+
multipleRenamesWithAssignment
334+
required_capability: rename_sequential_processing
335+
required_capability: rename_allow_assignment
336+
337+
ROW a="keyword", b=5, c=null
338+
| RENAME c = a, a = b
339+
| RENAME b = c
340+
| RENAME b = a, a = b
341+
;
342+
343+
a:integer
344+
5
345+
;

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// because the CSV tests don't support such assertions.
1010

1111
row
12-
required_capability: sample
12+
required_capability: sample_v2
1313

1414
ROW x = 1 | SAMPLE .999999999
1515
;
@@ -20,7 +20,7 @@ x:integer
2020

2121

2222
row and mv_expand
23-
required_capability: sample
23+
required_capability: sample_v2
2424

2525
ROW x = [1,2,3,4,5] | MV_EXPAND x | SAMPLE .999999999
2626
;
@@ -35,7 +35,7 @@ x:integer
3535

3636

3737
adjust stats for sampling
38-
required_capability: sample
38+
required_capability: sample_v2
3939

4040
FROM employees
4141
| SAMPLE 0.5
@@ -53,7 +53,7 @@ true
5353

5454

5555
before where
56-
required_capability: sample
56+
required_capability: sample_v2
5757

5858
FROM employees
5959
| SAMPLE 0.5
@@ -71,7 +71,7 @@ true
7171

7272

7373
after where
74-
required_capability: sample
74+
required_capability: sample_v2
7575

7676
FROM employees
7777
| WHERE emp_no <= 10050
@@ -89,7 +89,7 @@ true
8989

9090

9191
before sort
92-
required_capability: sample
92+
required_capability: sample_v2
9393

9494
FROM employees
9595
| SAMPLE 0.5
@@ -107,7 +107,7 @@ true
107107

108108

109109
after sort
110-
required_capability: sample
110+
required_capability: sample_v2
111111

112112
FROM employees
113113
| SORT emp_no
@@ -125,7 +125,7 @@ true
125125

126126

127127
before limit
128-
required_capability: sample
128+
required_capability: sample_v2
129129

130130
FROM employees
131131
| SAMPLE 0.5
@@ -141,7 +141,7 @@ true
141141

142142

143143
after limit
144-
required_capability: sample
144+
required_capability: sample_v2
145145

146146
FROM employees
147147
| LIMIT 50
@@ -158,7 +158,7 @@ true
158158

159159

160160
before mv_expand
161-
required_capability: sample
161+
required_capability: sample_v2
162162

163163
ROW x = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50], y = [1,2]
164164
| MV_EXPAND x
@@ -176,7 +176,7 @@ true
176176

177177

178178
after mv_expand
179-
required_capability: sample
179+
required_capability: sample_v2
180180

181181
ROW x = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50], y = [1,2]
182182
| MV_EXPAND x
@@ -194,7 +194,7 @@ true
194194

195195

196196
multiple samples
197-
required_capability: sample
197+
required_capability: sample_v2
198198

199199
FROM employees
200200
| SAMPLE 0.7
@@ -213,7 +213,7 @@ true
213213

214214

215215
after stats
216-
required_capability: sample
216+
required_capability: sample_v2
217217

218218
FROM employees
219219
| SAMPLE 0.5

x-pack/plugin/esql/src/main/antlr/EsqlBaseParser.g4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ renameCommand
212212

213213
renameClause:
214214
oldName=qualifiedNamePattern AS newName=qualifiedNamePattern
215+
| newName=qualifiedNamePattern ASSIGN oldName=qualifiedNamePattern
215216
;
216217

217218
dissectCommand

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,11 @@ public enum Cap {
439439
*/
440440
RENAME_SEQUENTIAL_PROCESSING,
441441

442+
/**
443+
* Support for assignment in RENAME, besides the use of `AS` keyword.
444+
*/
445+
RENAME_ALLOW_ASSIGNMENT,
446+
442447
/**
443448
* Support for removing empty attribute in merging output.
444449
* See <a href="https://github.com/elastic/elasticsearch/issues/126392"> ESQL: EVAL after STATS produces an empty column #126392 </a>
@@ -1077,7 +1082,7 @@ public enum Cap {
10771082
/**
10781083
* Support for the SAMPLE command
10791084
*/
1080-
SAMPLE(Build.current().isSnapshot()),
1085+
SAMPLE_V2(Build.current().isSnapshot()),
10811086

10821087
/**
10831088
* The {@code _query} API now gives a cast recommendation if multiple types are found in certain instances.

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseParser.interp

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)