Skip to content

Commit 08f11e0

Browse files
committed
Use WITH for options
1 parent 78602a0 commit 08f11e0

File tree

11 files changed

+1408
-1435
lines changed

11 files changed

+1408
-1435
lines changed

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ required_capability: metadata_score
168168
FROM books METADATA _id, _index, _score
169169
| FORK ( WHERE title:"Tolkien" | SORT _score, _id DESC | LIMIT 3 )
170170
( WHERE author:"Tolkien" | SORT _score, _id DESC | LIMIT 3 )
171-
| FUSE rrf OPTIONS {"rank_constant": 50 }
171+
| FUSE rrf WITH {"rank_constant": 50 }
172172
| SORT _score DESC, _id, _index
173173
| EVAL _fork = mv_sort(_fork)
174174
| EVAL _score = round(_score, 5)
@@ -192,7 +192,7 @@ required_capability: metadata_score
192192
FROM books METADATA _id, _index, _score
193193
| FORK ( WHERE title:"Tolkien" | SORT _score, _id DESC | LIMIT 3 )
194194
( WHERE author:"Tolkien" | SORT _score, _id DESC | LIMIT 3 )
195-
| FUSE rrf OPTIONS {"weights": { "fork1": 0.3, "fork2": 0.7 } }
195+
| FUSE rrf WITH {"weights": { "fork1": 0.3, "fork2": 0.7 } }
196196
| SORT _score DESC, _id, _index
197197
| EVAL _fork = mv_sort(_fork)
198198
| EVAL _score = round(_score, 5)
@@ -219,7 +219,7 @@ FROM books METADATA _id, _score
219219
( WHERE author:"Tolkien" | SORT _score, _id DESC | LIMIT 3
220220
| EVAL new_id = CONCAT(_id, _id), new_score = _score + 1, new_fork = "B")
221221
| DROP _id, _score
222-
| FUSE rrf KEY new_fork GROUP new_id SCORE new_score OPTIONS {"rank_constant": 60, "weights": { "fork1": 0.3, "fork2": 0.7 } }
222+
| FUSE rrf KEY new_fork GROUP new_id SCORE new_score WITH {"rank_constant": 60, "weights": { "fork1": 0.3, "fork2": 0.7 } }
223223
| SORT new_score DESC, new_id
224224
| EVAL new_fork = mv_sort(new_fork)
225225
| EVAL new_score = round(new_score, 5)
@@ -322,7 +322,7 @@ FROM books METADATA _id, _score
322322
| EVAL new_fork = CASE (_fork == "fork1", "A", "B")
323323
| EVAL new_score = _score * 2
324324
| DROP _fork, _score
325-
| FUSE rrf KEY new_fork GROUP new_id SCORE new_score OPTIONS {"rank_constant": 60, "weights": { "fork1": 0.3, "fork2": 0.7 } }
325+
| FUSE rrf KEY new_fork GROUP new_id SCORE new_score WITH {"rank_constant": 60, "weights": { "fork1": 0.3, "fork2": 0.7 } }
326326
| SORT new_score DESC, new_id
327327
| EVAL new_fork = mv_sort(new_fork)
328328
| EVAL new_score = round(new_score, 5)
@@ -371,7 +371,7 @@ required_capability: metadata_score
371371
FROM books METADATA _id, _index, _score
372372
| FORK ( WHERE title:"Tolkien" | SORT _score, _id DESC | LIMIT 3 )
373373
( WHERE author:"Tolkien" | SORT _score, _id DESC | LIMIT 3 )
374-
| FUSE linear OPTIONS {"normalizer": "l2_norm"}
374+
| FUSE linear WITH {"normalizer": "l2_norm"}
375375
| SORT _score DESC, _id, _index
376376
| EVAL _fork = mv_sort(_fork)
377377
| EVAL _score = round(_score, 5)
@@ -396,7 +396,7 @@ required_capability: metadata_score
396396
FROM books METADATA _id, _index, _score
397397
| FORK ( WHERE title:"Tolkien" | SORT _score, _id DESC | LIMIT 3 )
398398
( WHERE author:"Tolkien" | SORT _score, _id DESC | LIMIT 3 )
399-
| FUSE linear OPTIONS {"normalizer": "minmax"}
399+
| FUSE linear WITH {"normalizer": "minmax"}
400400
| SORT _score DESC, _id, _index
401401
| EVAL _fork = mv_sort(_fork)
402402
| EVAL _score = round(_score, 5)
@@ -420,7 +420,7 @@ required_capability: metadata_score
420420
FROM books METADATA _id, _index, _score
421421
| FORK ( WHERE title:"Tolkien" | SORT _score, _id DESC | LIMIT 3 )
422422
( WHERE author:"Tolkien" | SORT _score, _id DESC | LIMIT 3 )
423-
| FUSE linear OPTIONS {"weights": { "fork1": 0.3, "fork2": 0.7 }}
423+
| FUSE linear WITH {"weights": { "fork1": 0.3, "fork2": 0.7 }}
424424
| SORT _score DESC, _id, _index
425425
| EVAL _fork = mv_sort(_fork)
426426
| EVAL _score = round(_score, 5)
@@ -445,7 +445,7 @@ required_capability: metadata_score
445445
FROM books METADATA _id, _index, _score
446446
| FORK ( WHERE title:"Tolkien" | SORT _score, _id DESC | LIMIT 3 )
447447
( WHERE author:"Tolkien" | SORT _score, _id DESC | LIMIT 3 )
448-
| FUSE linear OPTIONS {"weights": { "fork1": 0.3, "inexistent": 0.7 }}
448+
| FUSE linear WITH {"weights": { "fork1": 0.3, "inexistent": 0.7 }}
449449
| SORT _score DESC, _id, _index
450450
| EVAL _fork = mv_sort(_fork)
451451
| EVAL _score = round(_score, 5)
@@ -470,7 +470,7 @@ required_capability: metadata_score
470470
FROM books METADATA _id, _index, _score
471471
| FORK ( WHERE title:"Tolkien" | SORT _score, _id DESC | LIMIT 3 )
472472
( WHERE author:"Tolkien" | SORT _score, _id DESC | LIMIT 3 )
473-
| FUSE linear OPTIONS {"normalizer": "minmax", "weights": { "fork1": 0.3, "fork2": 0.7 }}
473+
| FUSE linear WITH {"normalizer": "minmax", "weights": { "fork1": 0.3, "fork2": 0.7 }}
474474
| SORT _score DESC, _id, _index
475475
| EVAL _fork = mv_sort(_fork)
476476
| EVAL _score = round(_score, 5)
@@ -575,7 +575,7 @@ FROM books METADATA _id, _score
575575
| EVAL new_fork = CASE (_fork == "fork1", "A", "B")
576576
| EVAL new_score = _score * 2
577577
| DROP _fork, _score
578-
| FUSE LINEAR KEY new_fork GROUP new_id SCORE new_score OPTIONS {"normalizer": "minmax", "weights": { "fork1": 0.3, "fork2": 0.7 }}
578+
| FUSE LINEAR KEY new_fork GROUP new_id SCORE new_score WITH {"normalizer": "minmax", "weights": { "fork1": 0.3, "fork2": 0.7 }}
579579
| SORT new_score DESC, new_id
580580
| EVAL new_fork = mv_sort(new_fork)
581581
| EVAL new_score = round(new_score, 5)

x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/FuseIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public void testFuseRrf() {
3939
| FORK
4040
( WHERE content:"fox" | SORT _score, _id DESC )
4141
( WHERE content:"dog" | SORT _score, _id DESC )
42-
| FUSE RRF OPTIONS {"weights": { "fork1": 0.4, "fork2": 0.6}}
42+
| FUSE RRF WITH {"weights": { "fork1": 0.4, "fork2": 0.6}}
4343
| SORT _score DESC, _id, _index
4444
| EVAL _fork = mv_sort(_fork)
4545
| EVAL _score = round(_score, 4)
@@ -65,7 +65,7 @@ public void testFuseLinear() {
6565
| FORK
6666
( WHERE content:"fox" | SORT _score, _id DESC )
6767
( WHERE content:"dog" | SORT _score, _id DESC )
68-
| FUSE LINEAR OPTIONS {"weights": { "fork1": 0.4, "fork2": 0.6}, "normalizer": "l2_norm"}
68+
| FUSE LINEAR WITH {"weights": { "fork1": 0.4, "fork2": 0.6}, "normalizer": "l2_norm"}
6969
| SORT _score DESC
7070
| EVAL _fork = mv_sort(_fork)
7171
| EVAL _score = round(_score, 4)

x-pack/plugin/esql/src/main/antlr/EsqlBaseLexer.tokens

Lines changed: 33 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ insistCommand
321321
;
322322

323323
fuseCommand
324-
: DEV_FUSE (fuseType=fuseMethod)? (KEY key=qualifiedName)? (GROUP group=fields)? (SCORE score=qualifiedName)? (OPTIONS fuseOptions=mapExpression)?
324+
: DEV_FUSE (fuseType=fuseMethod)? (KEY key=qualifiedName)? (GROUP group=fields)? (SCORE score=qualifiedName)? fuseOptions=commandNamedParameters
325325
;
326326

327327
fuseMethod

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

Lines changed: 33 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/src/main/antlr/lexer/Fuse.g4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ SCORE: 'score';
1919
KEY : 'key';
2020
RRF : 'rrf';
2121
LINEAR: 'linear';
22-
OPTIONS: 'options' -> popMode, pushMode(EXPRESSION_MODE);
2322

23+
FUSE_WITH: WITH -> type(WITH), popMode, pushMode(EXPRESSION_MODE);
2424
FUSE_COMMA: COMMA -> type(COMMA);
2525
FUSE_QUOTED_IDENTIFIER: QUOTED_IDENTIFIER -> type(QUOTED_IDENTIFIER);
2626
FUSE_UNQUOTED_IDENTIFIER: UNQUOTED_IDENTIFIER -> type(UNQUOTED_IDENTIFIER);

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

Lines changed: 2 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)