mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-08 22:32:55 +00:00
* feat: ttl zero filter * refactor: use TimeToLive enum * fix: unit test * tests: sqlness * refactor: Option<TTL> None means UNSET * tests: sqlness * fix: 10000 years --> forever * chore: minor refactor from reviews * chore: rename back TimeToLive * refactor: split imme request from normal requests * fix: use correct lifetime * refactor: rename immediate to instant * tests: flow sink table default ttl * refactor: per review * tests: sqlness * fix: ttl alter to instant * tests: sqlness * refactor: per review * chore: per review * feat: add db ttl type&forbid instant for db * tests: more unit test
167 lines
2.1 KiB
SQL
167 lines
2.1 KiB
SQL
CREATE TABLE test_ttl(
|
|
ts TIMESTAMP TIME INDEX,
|
|
val INT,
|
|
PRIMARY KEY (`val`)
|
|
) WITH (ttl = 'instant');
|
|
|
|
SHOW CREATE TABLE test_ttl;
|
|
|
|
INSERT INTO
|
|
test_ttl
|
|
VALUES
|
|
(now(), 1),
|
|
(now(), 2),
|
|
(now(), 3);
|
|
|
|
SELECT
|
|
val
|
|
from
|
|
test_ttl
|
|
ORDER BY
|
|
val;
|
|
|
|
-- SQLNESS SLEEP 2s
|
|
ADMIN flush_table('test_ttl');
|
|
|
|
ADMIN compact_table('test_ttl');
|
|
|
|
SELECT
|
|
val
|
|
from
|
|
test_ttl
|
|
ORDER BY
|
|
val;
|
|
|
|
ALTER TABLE
|
|
test_ttl UNSET 'ttl';
|
|
|
|
INSERT INTO
|
|
test_ttl
|
|
VALUES
|
|
(now(), 1),
|
|
(now(), 2),
|
|
(now(), 3);
|
|
|
|
SELECT
|
|
val
|
|
from
|
|
test_ttl
|
|
ORDER BY
|
|
val;
|
|
|
|
DROP TABLE test_ttl;
|
|
|
|
CREATE TABLE test_ttl(
|
|
ts TIMESTAMP TIME INDEX,
|
|
val INT,
|
|
PRIMARY KEY (`val`)
|
|
) WITH (ttl = '1s');
|
|
|
|
SHOW CREATE TABLE test_ttl;
|
|
|
|
INSERT INTO
|
|
test_ttl
|
|
VALUES
|
|
(now(), 1),
|
|
(now(), 2),
|
|
(now(), 3);
|
|
|
|
SELECT
|
|
val
|
|
from
|
|
test_ttl
|
|
ORDER BY
|
|
val;
|
|
|
|
ADMIN flush_table('test_ttl');
|
|
|
|
ADMIN compact_table('test_ttl');
|
|
|
|
SELECT
|
|
val
|
|
from
|
|
test_ttl
|
|
ORDER BY
|
|
val;
|
|
|
|
-- SQLNESS SLEEP 2s
|
|
ADMIN flush_table('test_ttl');
|
|
|
|
ADMIN compact_table('test_ttl');
|
|
|
|
SELECT
|
|
val
|
|
from
|
|
test_ttl
|
|
ORDER BY
|
|
val;
|
|
|
|
ALTER TABLE
|
|
test_ttl
|
|
SET
|
|
ttl = '1d';
|
|
|
|
INSERT INTO
|
|
test_ttl
|
|
VALUES
|
|
(now(), 1),
|
|
(now(), 2),
|
|
(now(), 3);
|
|
|
|
SELECT
|
|
val
|
|
from
|
|
test_ttl
|
|
ORDER BY
|
|
val;
|
|
|
|
ALTER TABLE
|
|
test_ttl
|
|
SET
|
|
ttl = 'instant';
|
|
|
|
ADMIN flush_table('test_ttl');
|
|
|
|
ADMIN compact_table('test_ttl');
|
|
|
|
SELECT
|
|
val
|
|
from
|
|
test_ttl
|
|
ORDER BY
|
|
val;
|
|
|
|
-- to make sure alter back and forth from duration to/from instant wouldn't break anything
|
|
ALTER TABLE
|
|
test_ttl
|
|
SET
|
|
ttl = '1s';
|
|
|
|
INSERT INTO
|
|
test_ttl
|
|
VALUES
|
|
(now(), 1),
|
|
(now(), 2),
|
|
(now(), 3);
|
|
|
|
SELECT
|
|
val
|
|
from
|
|
test_ttl
|
|
ORDER BY
|
|
val;
|
|
|
|
-- SQLNESS SLEEP 2s
|
|
ADMIN flush_table('test_ttl');
|
|
|
|
ADMIN compact_table('test_ttl');
|
|
|
|
SELECT
|
|
val
|
|
from
|
|
test_ttl
|
|
ORDER BY
|
|
val;
|
|
|
|
DROP TABLE test_ttl;
|