-
Notifications
You must be signed in to change notification settings - Fork 25.3k
ES|QL: enable EXPLAIN (snapshot only) #129526
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
base: main
Are you sure you want to change the base?
Conversation
03588d2
to
453ad04
Compare
| rowCommand | ||
| showCommand | ||
// in development | ||
| {this.isDevVersion()}? timeSeriesCommand | ||
| {this.isDevVersion()}? explainCommand |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving it to dev mode. It didn't work before, so there is really no reason to have it in the GA grammar
; | ||
|
||
subqueryExpression | ||
: OPENING_BRACKET query CLOSING_BRACKET | ||
: LP query RP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aligned with FORK
Pinging @elastic/es-analytical-engine (Team:Analytics) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 for making int snapshot only until that is properly finalized
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. And surely, dev mode suits it better than GA
@@ -23,6 +23,9 @@ FROM_COMMA : COMMA -> type(COMMA); | |||
FROM_ASSIGN : ASSIGN -> type(ASSIGN); | |||
METADATA : 'metadata'; | |||
|
|||
// we need this for EXPLAIN | |||
FROM_RP : RP -> type(RP), popMode; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see this RP is missing from some modes:
Now, JOIN technically would fail anyway, as the "ON" token changes to expression mode, so the question is if we want it to fail at lexer or parser level (?).
My guess is that a query like EXPLAIN (FROM index | LOOKUP JOIN lookup)
would fail in different ways depending on this, but I'm not sure of which error we usually prefer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My actual concern is that every time we add a new command we'll have to do all this push/pop dance, but that's a broader topic...
About the error message, I'm not sure either
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if we add an EXPLAIN inside an EXPLAIN? I fear it could fail in the logical-to-physical conversion with a weird error. I would add a test of that here too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Today it's forbidden on purpose
@@ -207,6 +235,17 @@ public void executeOptimizedPlan( | |||
ActionListener<Result> listener | |||
) { | |||
PhysicalPlan physicalPlan = logicalPlanToPhysicalPlan(optimizedPlan, request); | |||
if (explainMode) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we pass these vars (explainMode, and the plan strings) as parameters instead? If I'm not wrong, calling session.execute() twice will leak those vars and break the second query. We're not doing that I think, but probably worth avoiding it (?)
Just saw that the Explain class has some old commented code. I would also remove it and clean it up a bit, as it looks ancient. |
Re-enabling a very basic EXPLAIN command.
It's in snapshot mode only for now, and it will be like that for a while probably.
The main purpose for now is to help development, but it could be refined and promoted to production eventually.
For now it's not a real command, in particular it doesn't do any compute, so it cannot be chained with further commands.
We could make it a real command, with evaluators and all the rest, but now the planning logic is very coupled into EsqlSession, so if we want EXPLAIN to be really representative of what happens in there, we'll have to keep it in there. Or refactor how planning works.
The syntax is
EXPLAIN ( <query> )
and produces information about parsed query, optimized logical plan and optimized physical planeg.
I'm using round parentheses (and not square brackets, as in the original syntax) just because FORK is already using them for subqueries, but it's something we can change.