mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-08-18 03:58:29 +00:00
feat: handle drop request for metric table (#3136)
* handle drop request Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * adjust procedure manager Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * add create table sqlness test Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * insert/query metric table Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * address CR comments Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * Update src/common/meta/src/kv_backend.rs Co-authored-by: JeremyHi <jiachun_feng@proton.me> * fix clippy Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * reuse region option for metadata region Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * tweak variable name Signed-off-by: Ruihang Xia <waynestxia@gmail.com> --------- Signed-off-by: Ruihang Xia <waynestxia@gmail.com> Co-authored-by: JeremyHi <jiachun_feng@proton.me>
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
CREATE TABLE phy (ts timestamp time index, val double) engine=metric with ("physical_metric_table" = "");
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
SHOW TABLES;
|
||||
|
||||
+---------+
|
||||
| Tables |
|
||||
+---------+
|
||||
| numbers |
|
||||
| phy |
|
||||
+---------+
|
||||
|
||||
CREATE TABLE t1 (ts timestamp time index, val double, host string primary key) engine = metric with ("on_physical_table" = "phy");
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE TABLE t2 (ts timestamp time index, job string primary key, val double) engine = metric with ("on_physical_table" = "phy");
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
SELECT * FROM information_schema.tables WHERE engine = "metric" order by table_name;
|
||||
|
||||
Error: 3000(PlanQuery), Failed to plan SQL: No field named metric. Valid fields are information_schema.tables.table_catalog, information_schema.tables.table_schema, information_schema.tables.table_name, information_schema.tables.table_type, information_schema.tables.table_id, information_schema.tables.engine.
|
||||
|
||||
-- We currently don't maintains physical table's schema.
|
||||
DESC TABLE phy;
|
||||
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
| Column | Type | Key | Null | Default | Semantic Type |
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
| ts | TimestampMillisecond | PRI | NO | | TIMESTAMP |
|
||||
| val | Float64 | | YES | | FIELD |
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
|
||||
DESC TABLE t1;
|
||||
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
| Column | Type | Key | Null | Default | Semantic Type |
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
| ts | TimestampMillisecond | PRI | NO | | TIMESTAMP |
|
||||
| val | Float64 | | YES | | FIELD |
|
||||
| host | String | PRI | YES | | TAG |
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
|
||||
DESC TABLE t2;
|
||||
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
| Column | Type | Key | Null | Default | Semantic Type |
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
| ts | TimestampMillisecond | PRI | NO | | TIMESTAMP |
|
||||
| job | String | PRI | YES | | TAG |
|
||||
| val | Float64 | | YES | | FIELD |
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
|
||||
-- TODO(ruihang): add a case that drops phy before t1
|
||||
DROP TABLE t1;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE t2;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE phy;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
CREATE TABLE phy (ts timestamp time index, val double) engine=metric with ("physical_metric_table" = "");
|
||||
|
||||
SHOW TABLES;
|
||||
|
||||
CREATE TABLE t1 (ts timestamp time index, val double, host string primary key) engine = metric with ("on_physical_table" = "phy");
|
||||
|
||||
CREATE TABLE t2 (ts timestamp time index, job string primary key, val double) engine = metric with ("on_physical_table" = "phy");
|
||||
|
||||
SELECT * FROM information_schema.tables WHERE engine = "metric" order by table_name;
|
||||
|
||||
-- We currently don't maintains physical table's schema.
|
||||
DESC TABLE phy;
|
||||
|
||||
DESC TABLE t1;
|
||||
|
||||
DESC TABLE t2;
|
||||
|
||||
-- TODO(ruihang): add a case that drops phy before t1
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
DROP TABLE t2;
|
||||
|
||||
DROP TABLE phy;
|
||||
@@ -0,0 +1,62 @@
|
||||
CREATE TABLE phy (ts timestamp time index, val double) engine=metric with ("physical_metric_table" = "");
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE TABLE t1 (ts timestamp time index, val double, host string primary key) engine = metric with ("on_physical_table" = "phy");
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO t1 VALUES (0, 0, 'host1'), (1, 1, 'host2');
|
||||
|
||||
Affected Rows: 2
|
||||
|
||||
SELECT * from t1;
|
||||
|
||||
+-------------------------+-----+-------+
|
||||
| ts | val | host |
|
||||
+-------------------------+-----+-------+
|
||||
| 1970-01-01T00:00:00.001 | 1.0 | host2 |
|
||||
| 1970-01-01T00:00:00 | 0.0 | host1 |
|
||||
+-------------------------+-----+-------+
|
||||
|
||||
-- TODO(ruihang): fix this. t2 should not contains data from t1
|
||||
CREATE TABLE t2 (ts timestamp time index, job string primary key, val double) engine = metric with ("on_physical_table" = "phy");
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
SELECT * from t2;
|
||||
|
||||
+-------------------------+-----+-----+
|
||||
| ts | job | val |
|
||||
+-------------------------+-----+-----+
|
||||
| 1970-01-01T00:00:00.001 | | 1.0 |
|
||||
| 1970-01-01T00:00:00 | | 0.0 |
|
||||
+-------------------------+-----+-----+
|
||||
|
||||
INSERT INTO t2 VALUES (0, 'job1', 0), (1, 'job2', 1);
|
||||
|
||||
Affected Rows: 2
|
||||
|
||||
SELECT * from t2;
|
||||
|
||||
+-------------------------+------+-----+
|
||||
| ts | job | val |
|
||||
+-------------------------+------+-----+
|
||||
| 1970-01-01T00:00:00.001 | | 1.0 |
|
||||
| 1970-01-01T00:00:00 | | 0.0 |
|
||||
| 1970-01-01T00:00:00.001 | job2 | 1.0 |
|
||||
| 1970-01-01T00:00:00 | job1 | 0.0 |
|
||||
+-------------------------+------+-----+
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE t2;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE phy;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
CREATE TABLE phy (ts timestamp time index, val double) engine=metric with ("physical_metric_table" = "");
|
||||
|
||||
CREATE TABLE t1 (ts timestamp time index, val double, host string primary key) engine = metric with ("on_physical_table" = "phy");
|
||||
|
||||
INSERT INTO t1 VALUES (0, 0, 'host1'), (1, 1, 'host2');
|
||||
|
||||
SELECT * from t1;
|
||||
|
||||
-- TODO(ruihang): fix this. t2 should not contains data from t1
|
||||
CREATE TABLE t2 (ts timestamp time index, job string primary key, val double) engine = metric with ("on_physical_table" = "phy");
|
||||
|
||||
SELECT * from t2;
|
||||
|
||||
INSERT INTO t2 VALUES (0, 'job1', 0), (1, 'job2', 1);
|
||||
|
||||
SELECT * from t2;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
DROP TABLE t2;
|
||||
|
||||
DROP TABLE phy;
|
||||
Reference in New Issue
Block a user