-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Support EXPLAIN ... FORMAT <indent | tree | json | graphviz > ...
#15166
base: main
Are you sure you want to change the base?
Conversation
d2e0d63
to
aa53939
Compare
aa53939
to
b23e3cd
Compare
EXPLAIN ... FORMAT <indent | tree | json | graphviz > ...
EXPLAIN ... FORMAT <indent | tree | json | graphviz > ...
b23e3cd
to
187f38e
Compare
describe_alias: _, | ||
.. | ||
} => { | ||
self.explain_to_plan(verbose, analyze, DFStatement::Statement(statement)) | ||
let format = format.map(|format| format.to_string()); |
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.
Not very related to this PR, will we change sqlparser part to use a String
instead of enum like here? (I'd prefer so, as it gives us more flexibility)
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 think that would be a fine idea to propose upstream in sqlparser
I am not aware of any plans at the moment
|
||
<pre> | ||
EXPLAIN [ANALYZE] [VERBOSE] statement | ||
EXPLAIN [ANALYZE] [VERBOSE] [FORMAT format] statement |
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.
Maybe also state here that using VERBOSE
and FORMAT
together is not supported (yet?) like ANALYZE
and FORMAT
below
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 will do so
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 tried to clarify in 398cf1824
187f38e
to
c965e8e
Compare
Co-authored-by: Ruihang Xia <[email protected]>
@@ -79,21 +78,6 @@ pub enum DisplayFormatType { | |||
TreeRender, | |||
} | |||
|
|||
impl FromStr for DisplayFormatType { |
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.
This is superceded by the ExplainFormat
@@ -434,3 +434,135 @@ drop table t1; | |||
|
|||
statement ok | |||
drop table t2; | |||
|
|||
## Tests for explain format |
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.
Here are the tests showing how this works
FYI @irenjj |
…o alamb/explan_format
Thanks @alamb ! |
I'll take a look at others later today.❤️ |
displayable(optimized_plan.as_ref()).to_stringified( | ||
e.verbose, | ||
FinalPhysicalPlan, | ||
DisplayFormatType::TreeRender, | ||
), |
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.
Maybe we can add a new function to handle tree
explain like display_pg_json
, then the third parameter is no longer needed as I found the values passed in below are all default values.
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.
That is a good idea -- I will try it
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 did it in a83ec4e and i think it looks much nicer ❤️
Thanks @alamb , others LGTM. |
This is a good idea -- thank you. I did it in 31f402d |
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.
Which issue does this PR close?
EXPLAIN
formats via SQL #15021Rationale for this change
I would like to be able to see more of the great explain plan code that DataFusion already has (see #15021 for details)
What changes are included in this PR?
Changes:
EXPLAIN VERBOSE FORMAT ...
indent
modetree
modepgjson
modegraphviz
modeHere is an example
Are these changes tested?
Are there any user-facing changes?