mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-05 04:42:56 +00:00
* feat: use flow batching engine broken: try using logical plan fix: use dummy catalog for logical plan fix: insert plan exec&sqlness grpc addr feat: use frontend instance in flownode in standalone feat: flow type in metasrv&fix: flush flow out of sync& column name alias tests: sqlness update tests: sqlness flow rebuild udpate chore: per review refactor: keep chnl mgr refactor: use catalog mgr for get table tests: use valid sql fix: add more check refactor: put flow type determine to frontend * chore: update proto * chore: update proto to main branch * fix: add locks for create/drop flow&docs: update docs * feat: flush_flow flush all ranges now * test: add align time window test * docs: explain `nodeid` use in check task * refactor: AddAutoColumnRewriter check for Projection * refactor: per review * fix: query without time window also clean dirty time window * chore: better logging * chore: add comments per review * refactor: per review * chore: per review * chore: per review rename args * refactor: per review partially * chore: update docs * chore: use better error variant * chore: better error variant * refactor: rename FlowWorkerManager to FlowStreamingEngine * rename again * refactor: per review * chore: rebase after #5963 merged * refactor: rename all flow_worker_manager occurs * docs: rm resolved TODO
67 lines
1.4 KiB
SQL
67 lines
1.4 KiB
SQL
-- blog usecase
|
|
CREATE TABLE velocity (
|
|
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
left_wheel FLOAT,
|
|
right_wheel FLOAT,
|
|
TIME INDEX(ts)
|
|
);
|
|
|
|
CREATE TABLE avg_speed (
|
|
avg_speed DOUBLE,
|
|
start_window TIMESTAMP TIME INDEX,
|
|
end_window TIMESTAMP,
|
|
update_at TIMESTAMP,
|
|
);
|
|
|
|
CREATE FLOW calc_avg_speed SINK TO avg_speed AS
|
|
SELECT
|
|
avg((left_wheel + right_wheel) / 2) as avg_speed,
|
|
date_bin(INTERVAL '5 second', ts) as start_window,
|
|
date_bin(INTERVAL '5 second', ts) + INTERVAL '5 second' as end_window,
|
|
FROM
|
|
velocity
|
|
WHERE
|
|
left_wheel > 0.5
|
|
AND right_wheel > 0.5
|
|
AND left_wheel < 60
|
|
AND right_wheel < 60
|
|
GROUP BY
|
|
start_window;
|
|
|
|
INSERT INTO
|
|
velocity
|
|
VALUES
|
|
("2021-07-01 00:00:00.200", 0.0, 0.7),
|
|
("2021-07-01 00:00:00.200", 0.0, 61.0),
|
|
("2021-07-01 00:00:02.500", 2.0, 1.0,);
|
|
|
|
-- SQLNESS REPLACE (ADMIN\sFLUSH_FLOW\('\w+'\)\s+\|\n\+-+\+\n\|\s+)[0-9]+\s+\| $1 FLOW_FLUSHED |
|
|
ADMIN FLUSH_FLOW('calc_avg_speed');
|
|
|
|
SELECT
|
|
avg_speed,
|
|
start_window
|
|
FROM
|
|
avg_speed;
|
|
|
|
INSERT INTO
|
|
velocity
|
|
VALUES
|
|
("2021-07-01 00:00:05.100", 5.0, 4.0),
|
|
("2021-07-01 00:00:09.600", 2.3, 2.1);
|
|
|
|
-- SQLNESS REPLACE (ADMIN\sFLUSH_FLOW\('\w+'\)\s+\|\n\+-+\+\n\|\s+)[0-9]+\s+\| $1 FLOW_FLUSHED |
|
|
ADMIN FLUSH_FLOW('calc_avg_speed');
|
|
|
|
SELECT
|
|
avg_speed,
|
|
start_window
|
|
FROM
|
|
avg_speed;
|
|
|
|
DROP FLOW calc_avg_speed;
|
|
|
|
DROP TABLE velocity;
|
|
|
|
DROP TABLE avg_speed;
|