forked from apache/horaedb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support INSERT INTO SELECT (apache#1536)
## Rationale Close apache#557. ## Detailed Changes When generating the insert logical plan, alse generate the select logical plan and store it in the insert plan. Then execute the select logical plan in the insert interpreter, convert the result records into RowGroup and then insert it. ## Test Plan CI
- Loading branch information
1 parent
ebc9f12
commit 7c14eac
Showing
7 changed files
with
487 additions
and
158 deletions.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
integration_tests/cases/env/local/dml/insert_into_select.result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
-- | ||
-- Licensed to the Apache Software Foundation (ASF) under one | ||
-- or more contributor license agreements. See the NOTICE file | ||
-- distributed with this work for additional information | ||
-- regarding copyright ownership. The ASF licenses this file | ||
-- to you under the Apache License, Version 2.0 (the | ||
-- "License"); you may not use this file except in compliance | ||
-- with the License. You may obtain a copy of the License at | ||
-- | ||
-- http://www.apache.org/licenses/LICENSE-2.0 | ||
-- | ||
-- Unless required by applicable law or agreed to in writing, | ||
-- software distributed under the License is distributed on an | ||
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
-- KIND, either express or implied. See the License for the | ||
-- specific language governing permissions and limitations | ||
-- under the License. | ||
-- | ||
DROP TABLE IF EXISTS `insert_into_select_table1`; | ||
|
||
affected_rows: 0 | ||
|
||
CREATE TABLE `insert_into_select_table1` ( | ||
`timestamp` timestamp NOT NULL, | ||
`value` int, | ||
`name` string, | ||
timestamp KEY (timestamp)) ENGINE=Analytic | ||
WITH( | ||
enable_ttl='false' | ||
); | ||
|
||
affected_rows: 0 | ||
|
||
INSERT INTO `insert_into_select_table1` (`timestamp`, `value`, `name`) | ||
VALUES | ||
(1, 100, "s1"), | ||
(2, 200, "s2"), | ||
(3, 300, "s3"); | ||
|
||
affected_rows: 3 | ||
|
||
DROP TABLE IF EXISTS `insert_into_select_table2`; | ||
|
||
affected_rows: 0 | ||
|
||
CREATE TABLE `insert_into_select_table2` ( | ||
`timestamp` timestamp NOT NULL, | ||
`value` int, | ||
`name` string NULL, | ||
timestamp KEY (timestamp)) ENGINE=Analytic | ||
WITH( | ||
enable_ttl='false' | ||
); | ||
|
||
affected_rows: 0 | ||
|
||
INSERT INTO `insert_into_select_table2` (`timestamp`, `value`) | ||
SELECT `timestamp`, `value` | ||
FROM `insert_into_select_table1`; | ||
|
||
affected_rows: 3 | ||
|
||
SELECT `timestamp`, `value`, `name` | ||
FROM `insert_into_select_table2`; | ||
|
||
timestamp,value,name, | ||
Timestamp(1),Int32(100),String(""), | ||
Timestamp(2),Int32(200),String(""), | ||
Timestamp(3),Int32(300),String(""), | ||
|
||
|
||
DROP TABLE `insert_into_select_table1`; | ||
|
||
affected_rows: 0 | ||
|
||
DROP TABLE `insert_into_select_table2`; | ||
|
||
affected_rows: 0 | ||
|
57 changes: 57 additions & 0 deletions
57
integration_tests/cases/env/local/dml/insert_into_select.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
-- | ||
-- Licensed to the Apache Software Foundation (ASF) under one | ||
-- or more contributor license agreements. See the NOTICE file | ||
-- distributed with this work for additional information | ||
-- regarding copyright ownership. The ASF licenses this file | ||
-- to you under the Apache License, Version 2.0 (the | ||
-- "License"); you may not use this file except in compliance | ||
-- with the License. You may obtain a copy of the License at | ||
-- | ||
-- http://www.apache.org/licenses/LICENSE-2.0 | ||
-- | ||
-- Unless required by applicable law or agreed to in writing, | ||
-- software distributed under the License is distributed on an | ||
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
-- KIND, either express or implied. See the License for the | ||
-- specific language governing permissions and limitations | ||
-- under the License. | ||
-- | ||
|
||
DROP TABLE IF EXISTS `insert_into_select_table1`; | ||
|
||
CREATE TABLE `insert_into_select_table1` ( | ||
`timestamp` timestamp NOT NULL, | ||
`value` int, | ||
`name` string, | ||
timestamp KEY (timestamp)) ENGINE=Analytic | ||
WITH( | ||
enable_ttl='false' | ||
); | ||
|
||
INSERT INTO `insert_into_select_table1` (`timestamp`, `value`, `name`) | ||
VALUES | ||
(1, 100, "s1"), | ||
(2, 200, "s2"), | ||
(3, 300, "s3"); | ||
|
||
DROP TABLE IF EXISTS `insert_into_select_table2`; | ||
|
||
CREATE TABLE `insert_into_select_table2` ( | ||
`timestamp` timestamp NOT NULL, | ||
`value` int, | ||
`name` string NULL, | ||
timestamp KEY (timestamp)) ENGINE=Analytic | ||
WITH( | ||
enable_ttl='false' | ||
); | ||
|
||
INSERT INTO `insert_into_select_table2` (`timestamp`, `value`) | ||
SELECT `timestamp`, `value` | ||
FROM `insert_into_select_table1`; | ||
|
||
SELECT `timestamp`, `value`, `name` | ||
FROM `insert_into_select_table2`; | ||
|
||
DROP TABLE `insert_into_select_table1`; | ||
|
||
DROP TABLE `insert_into_select_table2`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.