mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-10-21 11:22:31 +00:00
* fix: fence scoped flow repair snapshots Signed-off-by: discord9 <discord9@163.com> * test: trim duplicate flow task tests Signed-off-by: discord9 <discord9@163.com> * test: moreless Signed-off-by: discord9 <discord9@163.com> * refactor: simplify flow query failure fallback Signed-off-by: discord9 <discord9@163.com> * test: update need eval interval Signed-off-by: discord9 <discord9@163.com> * docs: for helper fn Signed-off-by: discord9 <discord9@163.com> * chore: less test Signed-off-by: discord9 <discord9@163.com> * refactor: per review Signed-off-by: discord9 <discord9@163.com> * test: update for eval interval Signed-off-by: discord9 <discord9@163.com> * fix: consume dirty windows after successful query Signed-off-by: discord9 <discord9@163.com> * test: rm useless tests Signed-off-by: discord9 <discord9@163.com> * test: standalone seq&rm dead if Signed-off-by: discord9 <discord9@163.com> * chore: move to pending window instead Signed-off-by: discord9 <discord9@163.com> * chore: mark full also call abandon_fenced_repair Signed-off-by: discord9 <discord9@163.com> * chore: instant for pending fenced repair Signed-off-by: discord9 <discord9@163.com> --------- Signed-off-by: discord9 <discord9@163.com>
332 lines
9.8 KiB
Plaintext
332 lines
9.8 KiB
Plaintext
-- test ttl = instant
|
|
CREATE TABLE distinct_basic (
|
|
"number" INT,
|
|
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
PRIMARY KEY(number),
|
|
TIME INDEX(ts)
|
|
)WITH ('ttl' = 'instant');
|
|
|
|
Affected Rows: 0
|
|
|
|
-- should fallback to streaming mode
|
|
-- SQLNESS REPLACE id=\d+ id=REDACTED
|
|
CREATE FLOW test_distinct_basic SINK TO out_distinct_basic EVAL INTERVAL '1m' AS
|
|
SELECT
|
|
DISTINCT number as dis
|
|
FROM
|
|
distinct_basic;
|
|
|
|
Affected Rows: 0
|
|
|
|
-- flow_options should have a flow_type:streaming
|
|
-- since source table's ttl=instant
|
|
SELECT flow_name, options FROM INFORMATION_SCHEMA.FLOWS;
|
|
|
|
+---------------------+---------------------------+
|
|
| flow_name | options |
|
|
+---------------------+---------------------------+
|
|
| test_distinct_basic | {"flow_type":"streaming"} |
|
|
+---------------------+---------------------------+
|
|
|
|
SHOW CREATE TABLE distinct_basic;
|
|
|
|
+----------------+-----------------------------------------------------------+
|
|
| Table | Create Table |
|
|
+----------------+-----------------------------------------------------------+
|
|
| distinct_basic | CREATE TABLE IF NOT EXISTS "distinct_basic" ( |
|
|
| | "number" INT NULL, |
|
|
| | "ts" TIMESTAMP(3) NOT NULL DEFAULT current_timestamp(), |
|
|
| | TIME INDEX ("ts"), |
|
|
| | PRIMARY KEY ("number") |
|
|
| | ) |
|
|
| | |
|
|
| | ENGINE=mito |
|
|
| | WITH( |
|
|
| | ttl = 'instant' |
|
|
| | ) |
|
|
+----------------+-----------------------------------------------------------+
|
|
|
|
-- SQLNESS REPLACE \d{4} REDACTED
|
|
SHOW CREATE TABLE out_distinct_basic;
|
|
|
|
+--------------------+---------------------------------------------------+
|
|
| Table | Create Table |
|
|
+--------------------+---------------------------------------------------+
|
|
| out_distinct_basic | CREATE TABLE IF NOT EXISTS "out_distinct_basic" ( |
|
|
| | "dis" INT NULL, |
|
|
| | "update_at" TIMESTAMP(3) NULL, |
|
|
| | "__ts_placeholder" TIMESTAMP(3) NOT NULL, |
|
|
| | TIME INDEX ("__ts_placeholder"), |
|
|
| | PRIMARY KEY ("dis") |
|
|
| | ) |
|
|
| | |
|
|
| | ENGINE=mito |
|
|
| | WITH( |
|
|
| | 'comment' = 'Sink table for flow flow-id=REDACTED' |
|
|
| | ) |
|
|
+--------------------+---------------------------------------------------+
|
|
|
|
-- SQLNESS SLEEP 3s
|
|
INSERT INTO
|
|
distinct_basic
|
|
VALUES
|
|
(20, "2021-07-01 00:00:00.200"),
|
|
(20, "2021-07-01 00:00:00.200"),
|
|
(22, "2021-07-01 00:00:00.600");
|
|
|
|
Affected Rows: 0
|
|
|
|
-- SQLNESS REPLACE (ADMIN\sFLUSH_FLOW\('\w+'\)\s+\|\n\+-+\+\n\|\s+)[0-9]+\s+\| $1 FLOW_FLUSHED |
|
|
ADMIN FLUSH_FLOW('test_distinct_basic');
|
|
|
|
+-----------------------------------------+
|
|
| ADMIN FLUSH_FLOW('test_distinct_basic') |
|
|
+-----------------------------------------+
|
|
| FLOW_FLUSHED |
|
|
+-----------------------------------------+
|
|
|
|
SELECT
|
|
dis
|
|
FROM
|
|
out_distinct_basic;
|
|
|
|
+-----+
|
|
| dis |
|
|
+-----+
|
|
| 20 |
|
|
| 22 |
|
|
+-----+
|
|
|
|
SELECT number FROM distinct_basic;
|
|
|
|
++
|
|
++
|
|
|
|
-- SQLNESS SLEEP 6s
|
|
ADMIN FLUSH_TABLE('distinct_basic');
|
|
|
|
+-------------------------------------+
|
|
| ADMIN FLUSH_TABLE('distinct_basic') |
|
|
+-------------------------------------+
|
|
| 0 |
|
|
+-------------------------------------+
|
|
|
|
INSERT INTO
|
|
distinct_basic
|
|
VALUES
|
|
(23, "2021-07-01 00:00:01.600");
|
|
|
|
Affected Rows: 0
|
|
|
|
-- SQLNESS REPLACE (ADMIN\sFLUSH_FLOW\('\w+'\)\s+\|\n\+-+\+\n\|\s+)[0-9]+\s+\| $1 FLOW_FLUSHED |
|
|
ADMIN FLUSH_FLOW('test_distinct_basic');
|
|
|
|
+-----------------------------------------+
|
|
| ADMIN FLUSH_FLOW('test_distinct_basic') |
|
|
+-----------------------------------------+
|
|
| FLOW_FLUSHED |
|
|
+-----------------------------------------+
|
|
|
|
SELECT
|
|
dis
|
|
FROM
|
|
out_distinct_basic;
|
|
|
|
+-----+
|
|
| dis |
|
|
+-----+
|
|
| 20 |
|
|
| 22 |
|
|
| 23 |
|
|
+-----+
|
|
|
|
SELECT number FROM distinct_basic;
|
|
|
|
++
|
|
++
|
|
|
|
DROP FLOW test_distinct_basic;
|
|
|
|
Affected Rows: 0
|
|
|
|
DROP TABLE distinct_basic;
|
|
|
|
Affected Rows: 0
|
|
|
|
DROP TABLE out_distinct_basic;
|
|
|
|
Affected Rows: 0
|
|
|
|
-- test ttl = 5s
|
|
CREATE TABLE distinct_basic (
|
|
"number" INT,
|
|
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
PRIMARY KEY(number),
|
|
TIME INDEX(ts)
|
|
)WITH ('ttl' = '5s');
|
|
|
|
Affected Rows: 0
|
|
|
|
CREATE FLOW test_distinct_basic SINK TO out_distinct_basic EVAL INTERVAL '1m' AS
|
|
SELECT
|
|
DISTINCT number as dis
|
|
FROM
|
|
distinct_basic;
|
|
|
|
Affected Rows: 0
|
|
|
|
-- flow_options should have a flow_type:batching
|
|
-- since source table's ttl=instant
|
|
SELECT flow_name, options FROM INFORMATION_SCHEMA.FLOWS;
|
|
|
|
+---------------------+--------------------------+
|
|
| flow_name | options |
|
|
+---------------------+--------------------------+
|
|
| test_distinct_basic | {"flow_type":"batching"} |
|
|
+---------------------+--------------------------+
|
|
|
|
-- SQLNESS ARG restart=true
|
|
SELECT 1;
|
|
|
|
+----------+
|
|
| Int64(1) |
|
|
+----------+
|
|
| 1 |
|
|
+----------+
|
|
|
|
-- SQLNESS SLEEP 3s
|
|
INSERT INTO
|
|
distinct_basic
|
|
VALUES
|
|
(20, "2021-07-01 00:00:00.200"),
|
|
(20, "2021-07-01 00:00:00.200"),
|
|
(22, "2021-07-01 00:00:00.600");
|
|
|
|
Affected Rows: 3
|
|
|
|
-- SQLNESS REPLACE (ADMIN\sFLUSH_FLOW\('\w+'\)\s+\|\n\+-+\+\n\|\s+)[0-9]+\s+\| $1 FLOW_FLUSHED |
|
|
ADMIN FLUSH_FLOW('test_distinct_basic');
|
|
|
|
+-----------------------------------------+
|
|
| ADMIN FLUSH_FLOW('test_distinct_basic') |
|
|
+-----------------------------------------+
|
|
| FLOW_FLUSHED |
|
|
+-----------------------------------------+
|
|
|
|
SHOW CREATE TABLE distinct_basic;
|
|
|
|
+----------------+-----------------------------------------------------------+
|
|
| Table | Create Table |
|
|
+----------------+-----------------------------------------------------------+
|
|
| distinct_basic | CREATE TABLE IF NOT EXISTS "distinct_basic" ( |
|
|
| | "number" INT NULL, |
|
|
| | "ts" TIMESTAMP(3) NOT NULL DEFAULT current_timestamp(), |
|
|
| | TIME INDEX ("ts"), |
|
|
| | PRIMARY KEY ("number") |
|
|
| | ) |
|
|
| | |
|
|
| | ENGINE=mito |
|
|
| | WITH( |
|
|
| | ttl = '5s' |
|
|
| | ) |
|
|
+----------------+-----------------------------------------------------------+
|
|
|
|
SHOW CREATE TABLE out_distinct_basic;
|
|
|
|
+--------------------+---------------------------------------------------+
|
|
| Table | Create Table |
|
|
+--------------------+---------------------------------------------------+
|
|
| out_distinct_basic | CREATE TABLE IF NOT EXISTS "out_distinct_basic" ( |
|
|
| | "dis" INT NULL, |
|
|
| | "update_at" TIMESTAMP(3) NULL, |
|
|
| | "__ts_placeholder" TIMESTAMP(3) NOT NULL, |
|
|
| | TIME INDEX ("__ts_placeholder"), |
|
|
| | PRIMARY KEY ("dis") |
|
|
| | ) |
|
|
| | |
|
|
| | ENGINE=mito |
|
|
| | WITH( |
|
|
| | 'comment' = 'Auto created table by flow engine' |
|
|
| | ) |
|
|
+--------------------+---------------------------------------------------+
|
|
|
|
SELECT
|
|
dis
|
|
FROM
|
|
out_distinct_basic;
|
|
|
|
+-----+
|
|
| dis |
|
|
+-----+
|
|
| 20 |
|
|
| 22 |
|
|
+-----+
|
|
|
|
SELECT number FROM distinct_basic;
|
|
|
|
+--------+
|
|
| number |
|
|
+--------+
|
|
| 20 |
|
|
| 22 |
|
|
+--------+
|
|
|
|
-- SQLNESS SLEEP 6s
|
|
ADMIN FLUSH_TABLE('distinct_basic');
|
|
|
|
+-------------------------------------+
|
|
| ADMIN FLUSH_TABLE('distinct_basic') |
|
|
+-------------------------------------+
|
|
| 0 |
|
|
+-------------------------------------+
|
|
|
|
INSERT INTO
|
|
distinct_basic
|
|
VALUES
|
|
(23, "2021-07-01 00:00:01.600");
|
|
|
|
Affected Rows: 1
|
|
|
|
-- SQLNESS REPLACE (ADMIN\sFLUSH_FLOW\('\w+'\)\s+\|\n\+-+\+\n\|\s+)[0-9]+\s+\| $1 FLOW_FLUSHED |
|
|
ADMIN FLUSH_FLOW('test_distinct_basic');
|
|
|
|
+-----------------------------------------+
|
|
| ADMIN FLUSH_FLOW('test_distinct_basic') |
|
|
+-----------------------------------------+
|
|
| FLOW_FLUSHED |
|
|
+-----------------------------------------+
|
|
|
|
SELECT
|
|
dis
|
|
FROM
|
|
out_distinct_basic;
|
|
|
|
+-----+
|
|
| dis |
|
|
+-----+
|
|
| 20 |
|
|
| 22 |
|
|
| 23 |
|
|
+-----+
|
|
|
|
SELECT number FROM distinct_basic;
|
|
|
|
+--------+
|
|
| number |
|
|
+--------+
|
|
| 23 |
|
|
+--------+
|
|
|
|
DROP FLOW test_distinct_basic;
|
|
|
|
Affected Rows: 0
|
|
|
|
DROP TABLE distinct_basic;
|
|
|
|
Affected Rows: 0
|
|
|
|
DROP TABLE out_distinct_basic;
|
|
|
|
Affected Rows: 0
|
|
|