mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-08-18 12:08:22 +00:00
78084a9d44
* feat: add admin function to discard unflushed data Signed-off-by: evenyag <realevenyag@gmail.com> * test: cover discarding unflushed data by table Signed-off-by: evenyag <realevenyag@gmail.com> * chore: fix license header Signed-off-by: evenyag <realevenyag@gmail.com> * fix: reject discarding logical metric table data Signed-off-by: evenyag <realevenyag@gmail.com> * refactor: defer table name formatting in error paths Signed-off-by: evenyag <realevenyag@gmail.com> * chore(deps): update greptime-proto revision Signed-off-by: evenyag <realevenyag@gmail.com> * refactor: rename discard unflushed admin function Signed-off-by: evenyag <realevenyag@gmail.com> --------- Signed-off-by: evenyag <realevenyag@gmail.com>
63 lines
1.9 KiB
SQL
63 lines
1.9 KiB
SQL
CREATE TABLE discard_unflushed_data_test (
|
|
host STRING PRIMARY KEY,
|
|
val DOUBLE,
|
|
ts TIMESTAMP TIME INDEX
|
|
) ENGINE = mito;
|
|
|
|
INSERT INTO discard_unflushed_data_test VALUES ('persisted', 1, 1);
|
|
|
|
ADMIN FLUSH_TABLE('discard_unflushed_data_test');
|
|
|
|
INSERT INTO discard_unflushed_data_test VALUES ('unflushed', 2, 2);
|
|
|
|
ADMIN discard_unflushed('discard_unflushed_data_test');
|
|
|
|
-- Repeating the operation is idempotent.
|
|
ADMIN discard_unflushed('discard_unflushed_data_test');
|
|
|
|
SELECT host, val FROM discard_unflushed_data_test ORDER BY host;
|
|
|
|
-- The function must only be available through ADMIN.
|
|
-- SQLNESS REPLACE \nDid\syou\smean.*
|
|
SELECT discard_unflushed(0);
|
|
|
|
DROP TABLE discard_unflushed_data_test;
|
|
|
|
CREATE TABLE discard_unflushed_data_test (
|
|
host STRING PRIMARY KEY,
|
|
val DOUBLE,
|
|
ts TIMESTAMP TIME INDEX
|
|
) ENGINE = mito;
|
|
|
|
INSERT INTO discard_unflushed_data_test VALUES ('unflushed', 1, 1);
|
|
|
|
-- The table has no persisted data, so discarding leaves it empty.
|
|
ADMIN discard_unflushed('discard_unflushed_data_test');
|
|
|
|
SELECT COUNT(*) FROM discard_unflushed_data_test;
|
|
|
|
DROP TABLE discard_unflushed_data_test;
|
|
|
|
CREATE TABLE discard_unflushed_data_physical (
|
|
ts TIMESTAMP TIME INDEX,
|
|
val DOUBLE
|
|
) ENGINE = metric WITH ("physical_metric_table" = "");
|
|
|
|
CREATE TABLE discard_unflushed_data_logical (
|
|
host STRING PRIMARY KEY,
|
|
val DOUBLE,
|
|
ts TIMESTAMP TIME INDEX
|
|
) ENGINE = metric WITH ("on_physical_table" = "discard_unflushed_data_physical");
|
|
|
|
INSERT INTO discard_unflushed_data_logical VALUES ('unflushed', 1, 1);
|
|
|
|
-- Logical Metric Engine tables share their physical regions with other logical tables.
|
|
-- Discarding by logical table name must not truncate those shared regions.
|
|
ADMIN discard_unflushed('discard_unflushed_data_logical');
|
|
|
|
SELECT host, val FROM discard_unflushed_data_logical;
|
|
|
|
DROP TABLE discard_unflushed_data_logical;
|
|
|
|
DROP TABLE discard_unflushed_data_physical;
|