apache / shardingsphere

Empowering Data Intelligence with Distributed SQL for Sharding, Scalability, and Security Across All Databases.
Apache License 2.0
19.9k stars 6.73k forks source link

Support MySQL/Oracle insert statement convert to SqlInsert to improve sql federation support #27376

Open strongduanmu opened 1 year ago

strongduanmu commented 1 year ago

Background

On the master branch, SQLNodeConverterEngine 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 INSERT statements and complex statements such as insert select, we need to support the conversion of InsertStatement in SQLNodeConverterEngine.

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

INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]
    [INTO] tbl_name
    [PARTITION (partition_name [, partition_name] ...)]
    [(col_name [, col_name] ...)]
    { {VALUES | VALUE} (value_list) [, (value_list)] ... }
    [AS row_alias[(col_alias [, col_alias] ...)]]
    [ON DUPLICATE KEY UPDATE assignment_list]

INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]
    [INTO] tbl_name
    [PARTITION (partition_name [, partition_name] ...)]
    SET assignment_list
    [AS row_alias[(col_alias [, col_alias] ...)]]
    [ON DUPLICATE KEY UPDATE assignment_list]

INSERT [LOW_PRIORITY | HIGH_PRIORITY] [IGNORE]
    [INTO] tbl_name
    [PARTITION (partition_name [, partition_name] ...)]
    [(col_name [, col_name] ...)]
    { SELECT ... 
      | TABLE table_name 
      | VALUES row_constructor_list
    }
    [ON DUPLICATE KEY UPDATE assignment_list]

value:
    {expr | DEFAULT}

value_list:
    value [, value] ...

row_constructor_list:
    ROW(value_list)[, ROW(value_list)][, ...]

assignment:
    col_name = 
          value
        | [row_alias.]col_name
        | [tbl_name.]col_name
        | [row_alias.]col_alias

assignment_list:
    assignment [, assignment] ...

Oracle insert statement doc - https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/INSERT.html#GUID-903F8043-0254-4EE9-ACC1-CB8AC0AF3423

Task

boyjoy1127 commented 1 year ago

I'd like to take care of this issue.

boyjoy1127 commented 1 year ago

I'd like to take care of this issue.

@strongduanmu

strongduanmu commented 1 year ago

@boyjoy1127 Welcome, I just assign this issue to you.

github-actions[bot] commented 1 year ago

There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.

github-actions[bot] commented 11 months ago

There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.