apache / apache/shardingsphere
Support MySQL/Oracle update statement convert to SqlUpdate to improve sql federation support
- 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 update statements and complex statements such as update join, we need to support the conversion of UpdateStatement in SQLNodeConverterEngine.
MySQL update statement doc - https://dev.mysql.com/doc/refman/8.0/en/update.html
```
UPDATE [LOW_PRIORITY] [IGNORE] table_reference
SET assignment_list
[WHERE where_condition]
[ORDER BY ...]
[LIMIT row_count]
value:
{expr | DEFAULT}
assignment:
col_name = value
assignment_list:
assignment [, assignment] ...
UPDATE [LOW_PRIORITY] [IGNORE] table_references
SET assignment_list
[WHERE where_condition]
```
Oracle update statement doc - https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/UPDATE.html#GUID-027A462D-379D-4E35-8611-410F3AC8FDA5
## Task
- [ ] add UpdateStatementConverter 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#L1110
- [ ] add UpdateStatementConverter call logic in SQLNodeConverterEngine
- [ ] add update statement convert test case in `resources/converter` directory
Contributor guide
Research direction
Start with SQLNodeConverterEngine.java and the existing SelectStatement conversion flow, then review the referenced FastSqlToCalciteNodeVisitor implementation. Add the UpdateStatementConverter and connect it in SQLNodeConverterEngine. Add update-statement conversion tests under the resources/converter directory; done means the requested MySQL and Oracle update forms are covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, mysql, sql
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100