apache / apache/shardingsphere

Support MySQL/Oracle delete statement convert to SqlDelete to improve sql federation support

Open
#27,377 7 comments 0 reactions 1 assignee Claimed by @kanha-gupta View on GitHub
feature: SQL federation type: enhancement
Dominant language
Java
Stars
20.8k
Forks
6.9k
Avg merge
11h 35m
Merged PRs (30d)
326

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 DELETE statements and complex statements such as delete join, we need to support the conversion of DeleteStatement in SQLNodeConverterEngine.

MySQL delete statement doc - https://dev.mysql.com/doc/refman/8.0/en/delete.html

```
DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM tbl_name [[AS] tbl_alias]
[PARTITION (partition_name [, partition_name] ...)]
[WHERE where_condition]
[ORDER BY ...]
[LIMIT row_count]

DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
tbl_name[.*] [, tbl_name[.*]] ...
FROM table_references
[WHERE where_condition]

DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
FROM tbl_name[.*] [, tbl_name[.*]] ...
USING table_references
[WHERE where_condition]
```

Oracle delete statement doc - https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/DELETE.html#GUID-156845A5-B626-412B-9F95-8869B988ABD7

## Task

- [ ] add DeleteStatementConverter 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#L1308
- [ ] add DeleteStatementConverter call logic in SQLNodeConverterEngine
- [ ] add delete 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.