Skip to content

feat: support insert multiple rows into a table using a single SQL insert statement. #398

Closed
@jingchen2222

Description

Is your feature request related to a problem? Please describe.

We are going to provide the ability to insert multiple database rows in a single SQL insert statement. The ANSI syntax for multi row is shown in the following demo.

Example 1: Insert 2 rows into table t1

CREATE TABLE t1 (
col1 int not null,
col5 bigint not null,
std_ts timestamp not null,
index(key=(col1), ts=col5)
);
      
INSERT INTO t1 VALUES (1, 10000L, 1590738987000L), (2, 20000L, 1590738988000L);

Example 2: Insert 2 rows into table t2 by specifying both the column names and the values to be inserted.

CREATE TABLE t2 (
col1 int not null,
col2 smallint,
col3 float,
col4 double,
col5 bigint not null,
std_date date not null,
str string,
INDEX(key=(col1), ts=col5)
);
INSERT INTO t2 (col1, col5, std_date) VALUES (1, 10000L, '2020-05-27'), (2, 20000L, '2020-05-28');

Describe the solution you'd like

The problem is we only get one single row from given insert statement. So we are going to modify function ExecuteInsert.

bool SQLClusterRouter::ExecuteInsert(const std::string& db, const std::string& sql, ::hybridse::sdk::Status* status) {
  // TODO 
  // parse a sql into a set of rows and put rows into storage one by one
}

More related discussion can be checked from #391.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions