apache / apache/shardingsphere
Support MySQL explain statement convert to SqlExplain to improve sql federation support
- Dominant language
- Java
- Stars
- 20.8k
- Forks
- 6.9k
- Avg merge
- 9h 55m
- Merged PRs (30d)
- 311
Description
## Background
On the master branch, [SQLNodeConverterEngine](https://github.com/apache/shardingsphere/blob/master/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/converter/SQLNodeConverterEngine.java) already supports the conversion of most SelectStatement statements, which provides a good foundation for sql federation. In order to improve the support of sql federation for explain statements and complex statements such as explain select, we need to support the conversion of ExplainStatement in SQLNodeConverterEngine.
MySQL explain statement doc - https://dev.mysql.com/doc/refman/8.0/en/explain.html
```
{EXPLAIN | DESCRIBE | DESC}
tbl_name [col_name | wild]
{EXPLAIN | DESCRIBE | DESC}
[explain_type]
{explainable_stmt | FOR CONNECTION connection_id}
{EXPLAIN | DESCRIBE | DESC} ANALYZE [FORMAT = TREE] select_statement
explain_type: {
FORMAT = format_name
}
format_name: {
TRADITIONAL
| JSON
| TREE
}
explainable_stmt: {
SELECT statement
| TABLE statement
| DELETE statement
| INSERT statement
| REPLACE statement
| UPDATE statement
}
```
## Task
- [ ] add ExplainStatementConverter implement, you can refer - https://github.com/polardb/polardbx-sql/blob/cdd976850bdfc3264dff279198b6b06eb8641fbe/polardbx-optimizer/src/main/java/com/alibaba/polardbx/optimizer/parse/visitor/FastSqlToCalciteNodeVisitor.java#L786
- [ ] add ExplainStatementConverter call logic in SQLNodeConverterEngine
- [ ] add explain statement convert test case in `resources/converter` directory
Contributor guide
Assessment
This issue has not been assessed yet.