Problem
Currently, ExplainPlanPlanVisitor.explain (code reference) provides the physical plan of the SQL query in a simple text format. One such example of the output is as follows.
[0]@localhost:3 MAIL_RECEIVE(RANDOM_DISTRIBUTED)
├── [1]@localhost:2 MAIL_SEND(RANDOM_DISTRIBUTED)->{[0]@localhost@{3,3}|[0]}
│ └── [1]@localhost:2 PROJECT
│ └── [1]@localhost:2 TABLE SCAN (a) null
└── [1]@localhost:1 MAIL_SEND(RANDOM_DISTRIBUTED)->{[0]@localhost@{3,3}|[0]}
└── [1]@localhost:1 PROJECT
└── [1]@localhost:1 TABLE SCAN (a) null
EXPLAIN PLAN FOR SQL query supports various formats(XML, JSON, DOT and TEXT), and with the solution approach to the issue(support explain on physical plan ); the output of the physical plan of the query should follow the same format as mentioned in the Explain Query.
Solution Approach
- Extend the
ExplainPlanPlanVisitor class for different output formats and generate the physical plan based on the format mentioned in the Explain query.
TEXT will be the default output format, if not mentioned in the Explain query.
NOTE
example of the Explain query with format option
EXPLAIN Plan As JSON Select * from airlineStats
labels:
cc: @walterddr