mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-06 21:32:58 +00:00
refactor: execute insert with select in query engine (#1181)
* refactor: execute insert with select in query engine * fix: resolve PR comments
This commit is contained in:
45
tests/cases/standalone/common/insert/insert_select.result
Normal file
45
tests/cases/standalone/common/insert/insert_select.result
Normal file
@@ -0,0 +1,45 @@
|
||||
create table demo1(host string, cpu double, memory double, ts timestamp time index);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
create table demo2(host string, cpu double, memory double, ts timestamp time index);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
insert into demo1(host, cpu, memory, ts) values ('host1', 66.6, 1024, 1655276557000), ('host2', 88.8, 333.3, 1655276558000);
|
||||
|
||||
Affected Rows: 2
|
||||
|
||||
insert into demo2(host) select * from demo1;
|
||||
|
||||
Error: 3000(PlanQuery), Error during planning: Column count doesn't match insert query!
|
||||
|
||||
insert into demo2 select cpu,memory from demo1;
|
||||
|
||||
Error: 3000(PlanQuery), Error during planning: Column count doesn't match insert query!
|
||||
|
||||
insert into demo2(ts) select memory from demo1;
|
||||
|
||||
Error: 3000(PlanQuery), Error during planning: Cannot automatically convert Float64 to Timestamp(Millisecond, None)
|
||||
|
||||
insert into demo2 select * from demo1;
|
||||
|
||||
Affected Rows: 2
|
||||
|
||||
select * from demo2 order by ts;
|
||||
|
||||
+-------+------+--------+---------------------+
|
||||
| host | cpu | memory | ts |
|
||||
+-------+------+--------+---------------------+
|
||||
| host1 | 66.6 | 1024.0 | 2022-06-15T07:02:37 |
|
||||
| host2 | 88.8 | 333.3 | 2022-06-15T07:02:38 |
|
||||
+-------+------+--------+---------------------+
|
||||
|
||||
drop table demo1;
|
||||
|
||||
Affected Rows: 1
|
||||
|
||||
drop table demo2;
|
||||
|
||||
Affected Rows: 1
|
||||
|
||||
19
tests/cases/standalone/common/insert/insert_select.sql
Normal file
19
tests/cases/standalone/common/insert/insert_select.sql
Normal file
@@ -0,0 +1,19 @@
|
||||
create table demo1(host string, cpu double, memory double, ts timestamp time index);
|
||||
|
||||
create table demo2(host string, cpu double, memory double, ts timestamp time index);
|
||||
|
||||
insert into demo1(host, cpu, memory, ts) values ('host1', 66.6, 1024, 1655276557000), ('host2', 88.8, 333.3, 1655276558000);
|
||||
|
||||
insert into demo2(host) select * from demo1;
|
||||
|
||||
insert into demo2 select cpu,memory from demo1;
|
||||
|
||||
insert into demo2(ts) select memory from demo1;
|
||||
|
||||
insert into demo2 select * from demo1;
|
||||
|
||||
select * from demo2 order by ts;
|
||||
|
||||
drop table demo1;
|
||||
|
||||
drop table demo2;
|
||||
Reference in New Issue
Block a user