alamb opened a new issue, #15021: URL: https://github.com/apache/datafusion/issues/15021
### Is your feature request related to a problem or challenge? Suggested by @waynexia https://github.com/apache/datafusion/issues/14914#issuecomment-2698684681 Currently, DataFusion supports `EXPLAIN` and `EXPLAIN ANALYZE` as documented here: https://datafusion.apache.org/user-guide/sql/explain.html#id1 Both those commands produce a text based explain format: ```sql > explain select * from values (1), (2); +---------------+---------------------------------------------------+ | plan_type | plan | +---------------+---------------------------------------------------+ | logical_plan | Values: (Int64(1)), (Int64(2)) | | physical_plan | DataSourceExec: partitions=1, partition_sizes=[1] | | | | +---------------+---------------------------------------------------+ 2 row(s) fetched. Elapsed 0.031 seconds. ``` DataFusion has at least three other text based ways to generate explain plans: * graphviz via [`displayable::graphviz`](https://docs.rs/datafusion/latest/datafusion/physical_plan/display/struct.DisplayableExecutionPlan.html#method.graphviz) * json via [pgjson](https://docs.rs/datafusion/latest/datafusion/logical_expr/enum.LogicalPlan.html#method.display_pg_json) * tree -- see https://github.com/apache/datafusion/issues/14914 Also, @milenkovicm suggested on https://github.com/apache/datafusion/issues/14914#issuecomment-2698392966 that getting an SVG version would also be useful As of now it is not possible to see those formats via `SQL` (you need to use the API or set a config option) ### Describe the solution you'd like I would like to be able to access the different explain formats via SQL ### Describe alternatives you've considered @waynexia suggests (and I agree) on https://github.com/apache/datafusion/issues/14914#issuecomment-2698684681 That we follow the `EXPLAIN [ANALYZE] FORMAT <format>` grammar?: ```sql EXPLAIN [ANALYZE] FORMAT <format> ``` So this would look something like ```sql -- show explain plan in default text format EXPLAIN SELECT * from foo -- show explain plan in tree format EXPLAIN FORMAT tree SELECT * from foo -- show explain plan in json format EXPLAIN FORMAT json SELECT * from foo -- ... ``` @waynexia suggests on https://github.com/apache/datafusion/issues/14914#issuecomment-2698684681 > For the setting side, how about using the existing `EXPLAIN [ANALYZE] FORMAT <format>` grammar? `sqlparser` can parse and generate a [`AnalyzeFormat`](https://docs.rs/sqlparser/0.54.0/sqlparser/ast/enum.AnalyzeFormat.html), which the planner can use. But our current implementation just drops this format field: https://github.com/apache/datafusion/blob/ed517efcf329de55e7a9d881d6d76d885bc3598d/datafusion/sql/src/statement.rs#L213-L222 > We can also try to support GRAPHVIZ format in this way However, It seems like AnalyzeFormat currently only supports Text, JSON, and GRAPHVIZ 🤔 https://docs.rs/sqlparser/latest/sqlparser/ast/enum.AnalyzeFormat.html ### Additional context _No response_ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org