mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-08 14:22:58 +00:00
* feat: add partial truncate Signed-off-by: discord9 <discord9@163.com> * fix: per review Signed-off-by: discord9 <discord9@163.com> * feat: add proto partial truncate kind Signed-off-by: discord9 <discord9@163.com> * chore: clippy Signed-off-by: discord9 <discord9@163.com> * chore: update branched proto Signed-off-by: discord9 <discord9@163.com> * feat: grpc support truncate WIP sql support Signed-off-by: discord9 <discord9@163.com> * wip: parse truncate range Signed-off-by: discord9 <discord9@163.com> * feat: truncate by range Signed-off-by: discord9 <discord9@163.com> * fix: truncate range display Signed-off-by: discord9 <discord9@163.com> * chore: resolve todo Signed-off-by: discord9 <discord9@163.com> * refactor: per review Signed-off-by: discord9 <discord9@163.com> * test: more invalid parse Signed-off-by: discord9 <discord9@163.com> * chore: per review Signed-off-by: discord9 <discord9@163.com> * refactor: per review Signed-off-by: discord9 <discord9@163.com> * chore: unused Signed-off-by: discord9 <discord9@163.com> * chore: per review Signed-off-by: discord9 <discord9@163.com> * chore: update branch Signed-off-by: discord9 <discord9@163.com> --------- Signed-off-by: discord9 <discord9@163.com>
162 lines
4.4 KiB
Plaintext
162 lines
4.4 KiB
Plaintext
TRUNCATE TABLE not_exists_table;
|
|
|
|
Error: 4001(TableNotFound), Table not found: greptime.public.not_exists_table
|
|
|
|
CREATE TABLE monitor (host STRING, ts TIMESTAMP, cpu DOUBLE DEFAULT 0, memory DOUBLE, TIME INDEX (ts), PRIMARY KEY(host));
|
|
|
|
Affected Rows: 0
|
|
|
|
INSERT INTO monitor(ts, host, cpu, memory) VALUES
|
|
(1695217652000, 'host1', 66.6, 1024),
|
|
(1695217652000, 'host2', 66.6, 1024),
|
|
(1695217652000, 'host3', 66.6, 1024),
|
|
(1695217654000, 'host1', 77.7, 2048),
|
|
(1695217654000, 'host2', 77.7, 2048),
|
|
(1695217654000, 'host3', 77.7, 2048),
|
|
(1695217656000, 'host1', 88.8, 4096),
|
|
(1695217656000, 'host2', 88.8, 4096),
|
|
(1695217656000, 'host3', 88.8, 4096);
|
|
|
|
Affected Rows: 9
|
|
|
|
SELECT ts, host, cpu, memory FROM monitor ORDER BY ts;
|
|
|
|
+---------------------+-------+------+--------+
|
|
| ts | host | cpu | memory |
|
|
+---------------------+-------+------+--------+
|
|
| 2023-09-20T13:47:32 | host1 | 66.6 | 1024.0 |
|
|
| 2023-09-20T13:47:32 | host2 | 66.6 | 1024.0 |
|
|
| 2023-09-20T13:47:32 | host3 | 66.6 | 1024.0 |
|
|
| 2023-09-20T13:47:34 | host1 | 77.7 | 2048.0 |
|
|
| 2023-09-20T13:47:34 | host2 | 77.7 | 2048.0 |
|
|
| 2023-09-20T13:47:34 | host3 | 77.7 | 2048.0 |
|
|
| 2023-09-20T13:47:36 | host1 | 88.8 | 4096.0 |
|
|
| 2023-09-20T13:47:36 | host2 | 88.8 | 4096.0 |
|
|
| 2023-09-20T13:47:36 | host3 | 88.8 | 4096.0 |
|
|
+---------------------+-------+------+--------+
|
|
|
|
TRUNCATE monitor;
|
|
|
|
Affected Rows: 0
|
|
|
|
SELECT ts, host, cpu, memory FROM monitor ORDER BY ts;
|
|
|
|
++
|
|
++
|
|
|
|
-- truncate with time range
|
|
INSERT INTO monitor(ts, host, cpu, memory) VALUES
|
|
(1695217652000, 'host1', 66.6, 1024),
|
|
(1695217652000, 'host2', 66.6, 1024),
|
|
(1695217652000, 'host3', 66.6, 1024),
|
|
(1695217654000, 'host1', 77.7, 2048),
|
|
(1695217654000, 'host2', 77.7, 2048),
|
|
(1695217654000, 'host3', 77.7, 2048),
|
|
(1695217656000, 'host1', 88.8, 4096),
|
|
(1695217656000, 'host2', 88.8, 4096),
|
|
(1695217656000, 'host3', 88.8, 4096);
|
|
|
|
Affected Rows: 9
|
|
|
|
ADMIN FLUSH_TABLE('monitor');
|
|
|
|
+------------------------------+
|
|
| ADMIN FLUSH_TABLE('monitor') |
|
|
+------------------------------+
|
|
| 0 |
|
|
+------------------------------+
|
|
|
|
INSERT INTO monitor(ts, host, cpu, memory) VALUES
|
|
(1700000000111, 'host42', 66.6, 1024);
|
|
|
|
Affected Rows: 1
|
|
|
|
ADMIN FLUSH_TABLE('monitor');
|
|
|
|
+------------------------------+
|
|
| ADMIN FLUSH_TABLE('monitor') |
|
|
+------------------------------+
|
|
| 0 |
|
|
+------------------------------+
|
|
|
|
SELECT ts, host, cpu, memory FROM monitor ORDER BY ts;
|
|
|
|
+-------------------------+--------+------+--------+
|
|
| ts | host | cpu | memory |
|
|
+-------------------------+--------+------+--------+
|
|
| 2023-09-20T13:47:32 | host1 | 66.6 | 1024.0 |
|
|
| 2023-09-20T13:47:32 | host2 | 66.6 | 1024.0 |
|
|
| 2023-09-20T13:47:32 | host3 | 66.6 | 1024.0 |
|
|
| 2023-09-20T13:47:34 | host1 | 77.7 | 2048.0 |
|
|
| 2023-09-20T13:47:34 | host2 | 77.7 | 2048.0 |
|
|
| 2023-09-20T13:47:34 | host3 | 77.7 | 2048.0 |
|
|
| 2023-09-20T13:47:36 | host1 | 88.8 | 4096.0 |
|
|
| 2023-09-20T13:47:36 | host2 | 88.8 | 4096.0 |
|
|
| 2023-09-20T13:47:36 | host3 | 88.8 | 4096.0 |
|
|
| 2023-11-14T22:13:20.111 | host42 | 66.6 | 1024.0 |
|
|
+-------------------------+--------+------+--------+
|
|
|
|
TRUNCATE monitor FILE RANGE (0, 1700000000000), (1700000000111, 1700000000200);
|
|
|
|
Affected Rows: 0
|
|
|
|
SELECT ts, host, cpu, memory FROM monitor ORDER BY ts;
|
|
|
|
++
|
|
++
|
|
|
|
INSERT INTO monitor(ts, host, cpu, memory) VALUES
|
|
(1695217660000, 'host1', 88.8, 4096),
|
|
(1695217662000, 'host2', 88.8, 4096),
|
|
(1695217664000, 'host3', 88.8, 4096);
|
|
|
|
Affected Rows: 3
|
|
|
|
SELECT ts, host, cpu, memory FROM monitor ORDER BY ts;
|
|
|
|
+---------------------+-------+------+--------+
|
|
| ts | host | cpu | memory |
|
|
+---------------------+-------+------+--------+
|
|
| 2023-09-20T13:47:40 | host1 | 88.8 | 4096.0 |
|
|
| 2023-09-20T13:47:42 | host2 | 88.8 | 4096.0 |
|
|
| 2023-09-20T13:47:44 | host3 | 88.8 | 4096.0 |
|
|
+---------------------+-------+------+--------+
|
|
|
|
TRUNCATE monitor;
|
|
|
|
Affected Rows: 0
|
|
|
|
SELECT ts, host, cpu, memory FROM monitor ORDER BY ts;
|
|
|
|
++
|
|
++
|
|
|
|
DROP TABLE monitor;
|
|
|
|
Affected Rows: 0
|
|
|
|
CREATE TABLE "MoNiToR" ("hOsT" STRING PRIMARY KEY, "tS" TIMESTAMP TIME INDEX, "cPu" DOUBLE DEFAULT 0);
|
|
|
|
Affected Rows: 0
|
|
|
|
TRUNCATE "MoNiToR";
|
|
|
|
Affected Rows: 0
|
|
|
|
DROP TABLE "MoNiToR";
|
|
|
|
Affected Rows: 0
|
|
|
|
CREATE TABLE MoNiToR (hOsT STRING PRIMARY KEY, tS TIMESTAMP TIME INDEX, cPu DOUBLE DEFAULT 0);
|
|
|
|
Affected Rows: 0
|
|
|
|
TRUNCATE MoNiToR;
|
|
|
|
Affected Rows: 0
|
|
|
|
DROP TABLE MoNiToR;
|
|
|
|
Affected Rows: 0
|
|
|