CREATE TABLE numbers_input_basic ( number INT, ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY(number), TIME INDEX(ts) ); Affected Rows: 0 CREATE FLOW test_numbers_basic SINK TO out_num_cnt_basic AS SELECT sum(number) FROM numbers_input_basic GROUP BY tumble(ts, '1 second', '2021-07-01 00:00:00'); Affected Rows: 0 -- TODO(discord9): confirm if it's necessary to flush flow here? -- because flush_flow result is at most 1 select flush_flow('test_numbers_basic')<=1; +----------------------------------------------------+ | flush_flow(Utf8("test_numbers_basic")) <= Int64(1) | +----------------------------------------------------+ | true | +----------------------------------------------------+ -- SQLNESS ARG restart=true INSERT INTO numbers_input_basic VALUES (20, "2021-07-01 00:00:00.200"), (22, "2021-07-01 00:00:00.600"); Affected Rows: 2 select flush_flow('test_numbers_basic')<=1; +----------------------------------------------------+ | flush_flow(Utf8("test_numbers_basic")) <= Int64(1) | +----------------------------------------------------+ | true | +----------------------------------------------------+ SELECT col_0, window_start, window_end FROM out_num_cnt_basic; +-------+---------------------+---------------------+ | col_0 | window_start | window_end | +-------+---------------------+---------------------+ | 42 | 2021-07-01T00:00:00 | 2021-07-01T00:00:01 | +-------+---------------------+---------------------+ select flush_flow('test_numbers_basic')<=1; +----------------------------------------------------+ | flush_flow(Utf8("test_numbers_basic")) <= Int64(1) | +----------------------------------------------------+ | true | +----------------------------------------------------+ INSERT INTO numbers_input_basic VALUES (23,"2021-07-01 00:00:01.000"), (24,"2021-07-01 00:00:01.500"); Affected Rows: 2 select flush_flow('test_numbers_basic')<=1; +----------------------------------------------------+ | flush_flow(Utf8("test_numbers_basic")) <= Int64(1) | +----------------------------------------------------+ | true | +----------------------------------------------------+ SELECT col_0, window_start, window_end FROM out_num_cnt_basic; +-------+---------------------+---------------------+ | col_0 | window_start | window_end | +-------+---------------------+---------------------+ | 42 | 2021-07-01T00:00:00 | 2021-07-01T00:00:01 | | 47 | 2021-07-01T00:00:01 | 2021-07-01T00:00:02 | +-------+---------------------+---------------------+ DROP FLOW test_numbers_basic; Affected Rows: 0 DROP TABLE numbers_input_basic; Affected Rows: 0 DROP TABLE out_num_cnt_basic; Affected Rows: 0 -- test interprete interval CREATE TABLE numbers_input_basic ( number INT, ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY(number), TIME INDEX(ts) ); Affected Rows: 0 create table out_num_cnt_basic ( number INT, ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP TIME INDEX); Affected Rows: 0 CREATE FLOW filter_numbers_basic SINK TO out_num_cnt_basic AS SELECT INTERVAL '1 day 1 second', INTERVAL '1 month 1 day 1 second', INTERVAL '1 year 1 month' FROM numbers_input_basic where number > 10; Affected Rows: 0 SHOW CREATE FLOW filter_numbers_basic; +----------------------+----------------------------------------------------------------------------------------------------------------------------------------------+ | Flow | Create Flow | +----------------------+----------------------------------------------------------------------------------------------------------------------------------------------+ | filter_numbers_basic | CREATE OR REPLACE FLOW IF NOT EXISTS filter_numbers_basic | | | SINK TO out_num_cnt_basic | | | AS SELECT INTERVAL '1 day 1 second', INTERVAL '1 month 1 day 1 second', INTERVAL '1 year 1 month' FROM numbers_input_basic WHERE number > 10 | +----------------------+----------------------------------------------------------------------------------------------------------------------------------------------+ drop flow filter_numbers_basic; Affected Rows: 0 drop table out_num_cnt_basic; Affected Rows: 0 drop table numbers_input_basic; Affected Rows: 0 CREATE TABLE bytes_log ( byte INT, ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP, -- event time TIME INDEX(ts) ); Affected Rows: 0 CREATE TABLE approx_rate ( rate FLOAT, time_window TIMESTAMP, update_at TIMESTAMP, TIME INDEX(time_window) ); Affected Rows: 0 CREATE FLOW find_approx_rate SINK TO approx_rate AS SELECT CAST((max(byte) - min(byte)) AS FLOAT)/30.0, date_bin(INTERVAL '30 second', ts) as time_window from bytes_log GROUP BY time_window; Affected Rows: 0 INSERT INTO bytes_log VALUES (101, '2025-01-01 00:00:01'), (300, '2025-01-01 00:00:29'); Affected Rows: 2 SELECT flush_flow('find_approx_rate')<=1; +--------------------------------------------------+ | flush_flow(Utf8("find_approx_rate")) <= Int64(1) | +--------------------------------------------------+ | true | +--------------------------------------------------+ SELECT rate, time_window FROM approx_rate; +----------+---------------------+ | rate | time_window | +----------+---------------------+ | 6.633333 | 2025-01-01T00:00:00 | +----------+---------------------+ INSERT INTO bytes_log VALUES (450, '2025-01-01 00:00:32'), (500, '2025-01-01 00:00:37'); Affected Rows: 2 SELECT flush_flow('find_approx_rate')<=1; +--------------------------------------------------+ | flush_flow(Utf8("find_approx_rate")) <= Int64(1) | +--------------------------------------------------+ | true | +--------------------------------------------------+ SELECT rate, time_window FROM approx_rate; +-----------+---------------------+ | rate | time_window | +-----------+---------------------+ | 6.633333 | 2025-01-01T00:00:00 | | 1.6666666 | 2025-01-01T00:00:30 | +-----------+---------------------+ DROP TABLE bytes_log; Affected Rows: 0 DROP FLOW find_approx_rate; Affected Rows: 0 DROP TABLE approx_rate; Affected Rows: 0