Skip to content

Commit a79bbff

Browse files
ES|QL: enable EXPLAIN (snapshot only) (#129526)
1 parent f1b2c8d commit a79bbff

File tree

16 files changed

+2293
-2177
lines changed

16 files changed

+2293
-2177
lines changed

x-pack/plugin/esql/qa/server/src/main/resources/explain.csv-spec

Lines changed: 0 additions & 19 deletions
This file was deleted.

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

Lines changed: 1 addition & 2 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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ query
3333
;
3434

3535
sourceCommand
36-
: explainCommand
37-
| fromCommand
36+
: fromCommand
3837
| rowCommand
3938
| showCommand
4039
// in development
4140
| {this.isDevVersion()}? timeSeriesCommand
41+
| {this.isDevVersion()}? explainCommand
4242
;
4343

4444
processingCommand
@@ -239,11 +239,11 @@ commandOption
239239
;
240240

241241
explainCommand
242-
: EXPLAIN subqueryExpression
242+
: DEV_EXPLAIN subqueryExpression
243243
;
244244

245245
subqueryExpression
246-
: OPENING_BRACKET query CLOSING_BRACKET
246+
: LP query RP
247247
;
248248

249249
showCommand

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

Lines changed: 1 addition & 2 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/Explain.g4

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ lexer grammar Explain;
99
//
1010
// Explain
1111
//
12-
EXPLAIN : 'explain' -> pushMode(EXPLAIN_MODE);
13-
12+
DEV_EXPLAIN : {this.isDevVersion()}? 'explain' -> pushMode(EXPLAIN_MODE);
1413

1514
mode EXPLAIN_MODE;
16-
EXPLAIN_OPENING_BRACKET : OPENING_BRACKET -> type(OPENING_BRACKET), pushMode(DEFAULT_MODE);
15+
EXPLAIN_LP : LP -> type(LP), pushMode(DEFAULT_MODE);
1716
EXPLAIN_PIPE : PIPE -> type(PIPE), popMode;
17+
1818
EXPLAIN_WS : WS -> channel(HIDDEN);
1919
EXPLAIN_LINE_COMMENT : LINE_COMMENT -> channel(HIDDEN);
2020
EXPLAIN_MULTILINE_COMMENT : MULTILINE_COMMENT -> channel(HIDDEN);

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ FROM_COMMA : COMMA -> type(COMMA);
2323
FROM_ASSIGN : ASSIGN -> type(ASSIGN);
2424
METADATA : 'metadata';
2525

26+
// we need this for EXPLAIN
27+
FROM_RP : RP -> type(RP), popMode;
28+
2629
// in 8.14 ` were not allowed
2730
// this has been relaxed in 8.15 since " is used for quoting
2831
fragment UNQUOTED_SOURCE_PART

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
@@ -1210,7 +1210,12 @@ public enum Cap {
12101210
*
12111211
* https://github.com/elastic/elasticsearch/issues/129322
12121212
*/
1213-
NO_PLAIN_STRINGS_IN_LITERALS;
1213+
NO_PLAIN_STRINGS_IN_LITERALS,
1214+
1215+
/**
1216+
* (Re)Added EXPLAIN command
1217+
*/
1218+
EXPLAIN(Build.current().isSnapshot());
12141219

12151220
private final boolean enabled;
12161221

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

Lines changed: 6 additions & 5 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/java/org/elasticsearch/xpack/esql/parser/EsqlBaseLexer.java

Lines changed: 1147 additions & 1133 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/java/org/elasticsearch/xpack/esql/parser/EsqlBaseParser.interp

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

0 commit comments

Comments
 (0)