apache / apache/shardingsphere

Support MySQL explain statement convert to SqlExplain to improve sql federation support

Open
#27,379 4 comments 0 reactions 1 assignee Claimed by @zihaoAK47 View on GitHub
feature: SQL federation type: enhancement
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.