-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support INSERT INTO SELECT #1536
Merged
Merged
Changes from 7 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
31e1b08
feat: support insert into select
dracoooooo 742cfe2
add integration test
dracoooooo a65af6b
fix unit test
dracoooooo 8a9d4d9
Merge branch 'main' into insert-into-select
dracoooooo 2d923d4
fix style error
dracoooooo ee0938d
fix format
dracoooooo 192aa48
remove redundant comment
dracoooooo d8ab484
minor fix
dracoooooo bcacd5a
Move new test case to local dir
dracoooooo a691bc4
tidy
jiacai2050 13c1ea2
remove clone_with_cleared_cache
jiacai2050 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
integration_tests/cases/common/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 | ||
|
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As said in #1538 (comment), sql with multiple tables may fails, so currently we can only enable this features in standalone mode.
In cluster mode, we can do a check to ensure tables belonging to same instance.
For now, you can move this test under local dir, something like
integration_tests/cases/env/local/dml/insert_into_select.sql