From 96d83794c1efe73bd75c4d6d6eaab1dda29ca26c Mon Sep 17 00:00:00 2001 From: discord9 Date: Wed, 19 Jun 2024 17:07:16 +0800 Subject: [PATCH] tests: some basic flow tests --- tests/cases/standalone/flow/basic.result | 12 ++ tests/cases/standalone/flow/basic.sql | 6 +- tests/cases/standalone/flow/df_func.result | 122 +++++++++++++++++++++ tests/cases/standalone/flow/df_func.sql | 42 ++++++- 4 files changed, 178 insertions(+), 4 deletions(-) create mode 100644 tests/cases/standalone/flow/df_func.result diff --git a/tests/cases/standalone/flow/basic.result b/tests/cases/standalone/flow/basic.result index ee5d7c8317a9..ea5d0180551a 100644 --- a/tests/cases/standalone/flow/basic.result +++ b/tests/cases/standalone/flow/basic.result @@ -47,3 +47,15 @@ SELECT col_0, window_start, window_end FROM out_num_cnt; | 47 | 2021-07-01T00:00:01 | 2021-07-01T00:00:02 | +-------+---------------------+---------------------+ +DROP FLOW test_numbers; + +Affected Rows: 0 + +DROP TABLE numbers_input; + +Affected Rows: 0 + +DROP TABLE out_num_cnt; + +Affected Rows: 0 + diff --git a/tests/cases/standalone/flow/basic.sql b/tests/cases/standalone/flow/basic.sql index 0ffa81985616..1ecceeae3f2c 100644 --- a/tests/cases/standalone/flow/basic.sql +++ b/tests/cases/standalone/flow/basic.sql @@ -24,4 +24,8 @@ VALUES (24,"2021-07-01 00:00:01.500"); -- SQLNESS SLEEP 2s -SELECT col_0, window_start, window_end FROM out_num_cnt; \ No newline at end of file +SELECT col_0, window_start, window_end FROM out_num_cnt; + +DROP FLOW test_numbers; +DROP TABLE numbers_input; +DROP TABLE out_num_cnt; \ No newline at end of file diff --git a/tests/cases/standalone/flow/df_func.result b/tests/cases/standalone/flow/df_func.result new file mode 100644 index 000000000000..52eceda45ccd --- /dev/null +++ b/tests/cases/standalone/flow/df_func.result @@ -0,0 +1,122 @@ +CREATE TABLE numbers_input_df_func ( + number INT, + ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY(number), + TIME INDEX(ts) +); + +Affected Rows: 0 + +CREATE FLOW test_numbers_df_func +SINK TO out_num_cnt_df_func +AS +SELECT sum(abs(number)) FROM numbers_input_df_func GROUP BY tumble(ts, '1 second', '2021-07-01 00:00:00'); + +Affected Rows: 0 + +INSERT INTO numbers_input_df_func +VALUES + (-20, "2021-07-01 00:00:00.200"), + (22, "2021-07-01 00:00:00.600"); + +Affected Rows: 2 + +-- SQLNESS SLEEP 2s +SELECT col_0, window_start, window_end FROM out_num_cnt_df_func; + ++-------+---------------------+---------------------+ +| col_0 | window_start | window_end | ++-------+---------------------+---------------------+ +| 42 | 2021-07-01T00:00:00 | 2021-07-01T00:00:01 | ++-------+---------------------+---------------------+ + +INSERT INTO numbers_input_df_func +VALUES + (23,"2021-07-01 00:00:01.000"), + (-24,"2021-07-01 00:00:01.500"); + +Affected Rows: 2 + +-- SQLNESS SLEEP 2s +SELECT col_0, window_start, window_end FROM out_num_cnt_df_func; + ++-------+---------------------+---------------------+ +| 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_df_func; + +Affected Rows: 0 + +DROP TABLE numbers_input_df_func; + +Affected Rows: 0 + +DROP TABLE out_num_cnt_df_func; + +Affected Rows: 0 + +CREATE TABLE numbers_input_df_func ( + number INT, + ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY(number), + TIME INDEX(ts) +); + +Affected Rows: 0 + +CREATE FLOW test_numbers_df_func +SINK TO out_num_cnt_df_func +AS +SELECT abs(sum(number)) FROM numbers_input_df_func GROUP BY tumble(ts, '1 second', '2021-07-01 00:00:00'); + +Affected Rows: 0 + +INSERT INTO numbers_input_df_func +VALUES + (-20, "2021-07-01 00:00:00.200"), + (22, "2021-07-01 00:00:00.600"); + +Affected Rows: 2 + +-- SQLNESS SLEEP 2s +SELECT col_0, window_start, window_end FROM out_num_cnt_df_func; + ++-------+---------------------+---------------------+ +| col_0 | window_start | window_end | ++-------+---------------------+---------------------+ +| 2 | 2021-07-01T00:00:00 | 2021-07-01T00:00:01 | ++-------+---------------------+---------------------+ + +INSERT INTO numbers_input_df_func +VALUES + (23,"2021-07-01 00:00:01.000"), + (-24,"2021-07-01 00:00:01.500"); + +Affected Rows: 2 + +-- SQLNESS SLEEP 2s +SELECT col_0, window_start, window_end FROM out_num_cnt_df_func; + ++-------+---------------------+---------------------+ +| col_0 | window_start | window_end | ++-------+---------------------+---------------------+ +| 2 | 2021-07-01T00:00:00 | 2021-07-01T00:00:01 | +| 1 | 2021-07-01T00:00:01 | 2021-07-01T00:00:02 | ++-------+---------------------+---------------------+ + +DROP FLOW test_numbers_df_func; + +Affected Rows: 0 + +DROP TABLE numbers_input_df_func; + +Affected Rows: 0 + +DROP TABLE out_num_cnt_df_func; + +Affected Rows: 0 + diff --git a/tests/cases/standalone/flow/df_func.sql b/tests/cases/standalone/flow/df_func.sql index 8e00a0f14a68..ae5a4196759a 100644 --- a/tests/cases/standalone/flow/df_func.sql +++ b/tests/cases/standalone/flow/df_func.sql @@ -10,7 +10,7 @@ SINK TO out_num_cnt_df_func AS SELECT sum(abs(number)) FROM numbers_input_df_func GROUP BY tumble(ts, '1 second', '2021-07-01 00:00:00'); -INSERT INTO test_numbers_df_func +INSERT INTO numbers_input_df_func VALUES (-20, "2021-07-01 00:00:00.200"), (22, "2021-07-01 00:00:00.600"); @@ -18,10 +18,46 @@ VALUES -- SQLNESS SLEEP 2s SELECT col_0, window_start, window_end FROM out_num_cnt_df_func; -INSERT INTO test_numbers_df_func +INSERT INTO numbers_input_df_func VALUES (23,"2021-07-01 00:00:01.000"), (-24,"2021-07-01 00:00:01.500"); -- SQLNESS SLEEP 2s -SELECT col_0, window_start, window_end FROM out_num_cnt_df_func; \ No newline at end of file +SELECT col_0, window_start, window_end FROM out_num_cnt_df_func; + +DROP FLOW test_numbers_df_func; +DROP TABLE numbers_input_df_func; +DROP TABLE out_num_cnt_df_func; + +CREATE TABLE numbers_input_df_func ( + number INT, + ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY(number), + TIME INDEX(ts) +); + +CREATE FLOW test_numbers_df_func +SINK TO out_num_cnt_df_func +AS +SELECT abs(sum(number)) FROM numbers_input_df_func GROUP BY tumble(ts, '1 second', '2021-07-01 00:00:00'); + +INSERT INTO numbers_input_df_func +VALUES + (-20, "2021-07-01 00:00:00.200"), + (22, "2021-07-01 00:00:00.600"); + +-- SQLNESS SLEEP 2s +SELECT col_0, window_start, window_end FROM out_num_cnt_df_func; + +INSERT INTO numbers_input_df_func +VALUES + (23,"2021-07-01 00:00:01.000"), + (-24,"2021-07-01 00:00:01.500"); + +-- SQLNESS SLEEP 2s +SELECT col_0, window_start, window_end FROM out_num_cnt_df_func; + +DROP FLOW test_numbers_df_func; +DROP TABLE numbers_input_df_func; +DROP TABLE out_num_cnt_df_func; \ No newline at end of file