From d408fdb3338ba7799fa82e51db0ff49a46522afc Mon Sep 17 00:00:00 2001 From: discord9 Date: Fri, 2 Aug 2024 16:16:17 +0800 Subject: [PATCH] test: sqlness test update --- .../standalone/common/flow/flow_basic.result | 53 ++++----- .../standalone/common/flow/flow_basic.sql | 9 +- .../common/flow/flow_call_df_func.result | 108 +++++++++--------- .../common/flow/flow_call_df_func.sql | 20 ++-- 4 files changed, 96 insertions(+), 94 deletions(-) diff --git a/tests/cases/standalone/common/flow/flow_basic.result b/tests/cases/standalone/common/flow/flow_basic.result index e5983ea8d424..d23dcf6a4a5d 100644 --- a/tests/cases/standalone/common/flow/flow_basic.result +++ b/tests/cases/standalone/common/flow/flow_basic.result @@ -39,13 +39,13 @@ select flush_flow('test_numbers_basic')<=1; | true | +----------------------------------------------------+ -SELECT col_0, window_start, window_end FROM out_num_cnt_basic; +SELECT "SUM(numbers_input_basic.number)", 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 | -+-------+---------------------+---------------------+ ++---------------------------------+---------------------+---------------------+ +| SUM(numbers_input_basic.number) | window_start | window_end | ++---------------------------------+---------------------+---------------------+ +| 42 | 2021-07-01T00:00:00 | 2021-07-01T00:00:01 | ++---------------------------------+---------------------+---------------------+ select flush_flow('test_numbers_basic')<=1; @@ -70,14 +70,14 @@ select flush_flow('test_numbers_basic')<=1; | true | +----------------------------------------------------+ -SELECT col_0, window_start, window_end FROM out_num_cnt_basic; +SELECT "SUM(numbers_input_basic.number)", 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 | -+-------+---------------------+---------------------+ ++---------------------------------+---------------------+---------------------+ +| SUM(numbers_input_basic.number) | 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; @@ -141,8 +141,9 @@ CREATE TABLE bytes_log ( Affected Rows: 0 +-- TODO(discord9): remove this after auto infer table's time index is impl CREATE TABLE approx_rate ( - rate FLOAT, + rate DOUBLE, time_window TIMESTAMP, update_at TIMESTAMP, TIME INDEX(time_window) @@ -153,7 +154,7 @@ 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; +SELECT CAST((max(byte) - min(byte)) AS FLOAT)/30.0 as rate, date_bin(INTERVAL '30 second', ts) as time_window from bytes_log GROUP BY time_window; Affected Rows: 0 @@ -173,11 +174,11 @@ SELECT flush_flow('find_approx_rate')<=1; SELECT rate, time_window FROM approx_rate; -+----------+---------------------+ -| rate | time_window | -+----------+---------------------+ -| 6.633333 | 2025-01-01T00:00:00 | -+----------+---------------------+ ++-------------------+---------------------+ +| rate | time_window | ++-------------------+---------------------+ +| 6.633333333333334 | 2025-01-01T00:00:00 | ++-------------------+---------------------+ INSERT INTO bytes_log VALUES (450, '2025-01-01 00:00:32'), @@ -195,12 +196,12 @@ SELECT flush_flow('find_approx_rate')<=1; SELECT rate, time_window FROM approx_rate; -+-----------+---------------------+ -| rate | time_window | -+-----------+---------------------+ -| 6.633333 | 2025-01-01T00:00:00 | -| 1.6666666 | 2025-01-01T00:00:30 | -+-----------+---------------------+ ++--------------------+---------------------+ +| rate | time_window | ++--------------------+---------------------+ +| 6.633333333333334 | 2025-01-01T00:00:00 | +| 1.6666666666666667 | 2025-01-01T00:00:30 | ++--------------------+---------------------+ DROP TABLE bytes_log; diff --git a/tests/cases/standalone/common/flow/flow_basic.sql b/tests/cases/standalone/common/flow/flow_basic.sql index dab3d78f836b..63b4abf041ea 100644 --- a/tests/cases/standalone/common/flow/flow_basic.sql +++ b/tests/cases/standalone/common/flow/flow_basic.sql @@ -21,7 +21,7 @@ VALUES select flush_flow('test_numbers_basic')<=1; -SELECT col_0, window_start, window_end FROM out_num_cnt_basic; +SELECT "SUM(numbers_input_basic.number)", window_start, window_end FROM out_num_cnt_basic; select flush_flow('test_numbers_basic')<=1; @@ -32,7 +32,7 @@ VALUES select flush_flow('test_numbers_basic')<=1; -SELECT col_0, window_start, window_end FROM out_num_cnt_basic; +SELECT "SUM(numbers_input_basic.number)", window_start, window_end FROM out_num_cnt_basic; DROP FLOW test_numbers_basic; DROP TABLE numbers_input_basic; @@ -66,8 +66,9 @@ CREATE TABLE bytes_log ( TIME INDEX(ts) ); +-- TODO(discord9): remove this after auto infer table's time index is impl CREATE TABLE approx_rate ( - rate FLOAT, + rate DOUBLE, time_window TIMESTAMP, update_at TIMESTAMP, TIME INDEX(time_window) @@ -76,7 +77,7 @@ CREATE TABLE approx_rate ( 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; +SELECT CAST((max(byte) - min(byte)) AS FLOAT)/30.0 as rate, date_bin(INTERVAL '30 second', ts) as time_window from bytes_log GROUP BY time_window; INSERT INTO bytes_log VALUES (101, '2025-01-01 00:00:01'), diff --git a/tests/cases/standalone/common/flow/flow_call_df_func.result b/tests/cases/standalone/common/flow/flow_call_df_func.result index bb4357fa611e..e7371adae366 100644 --- a/tests/cases/standalone/common/flow/flow_call_df_func.result +++ b/tests/cases/standalone/common/flow/flow_call_df_func.result @@ -39,13 +39,13 @@ select flush_flow('test_numbers_df_func')<=1; | true | +------------------------------------------------------+ -SELECT col_0, window_start, window_end FROM out_num_cnt_df_func; +SELECT "SUM(abs(numbers_input_df_func.number))", 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 | -+-------+---------------------+---------------------+ ++----------------------------------------+---------------------+---------------------+ +| SUM(abs(numbers_input_df_func.number)) | window_start | window_end | ++----------------------------------------+---------------------+---------------------+ +| 42 | 2021-07-01T00:00:00 | 2021-07-01T00:00:01 | ++----------------------------------------+---------------------+---------------------+ select flush_flow('test_numbers_df_func')<=1; @@ -70,14 +70,14 @@ select flush_flow('test_numbers_df_func')<=1; | true | +------------------------------------------------------+ -SELECT col_0, window_start, window_end FROM out_num_cnt_df_func; +SELECT "SUM(abs(numbers_input_df_func.number))", 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 | -+-------+---------------------+---------------------+ ++----------------------------------------+---------------------+---------------------+ +| SUM(abs(numbers_input_df_func.number)) | 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; @@ -132,13 +132,13 @@ select flush_flow('test_numbers_df_func')<=1; | true | +------------------------------------------------------+ -SELECT col_0, window_start, window_end FROM out_num_cnt_df_func; +SELECT "abs(SUM(numbers_input_df_func.number))", 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 | -+-------+---------------------+---------------------+ ++----------------------------------------+---------------------+---------------------+ +| abs(SUM(numbers_input_df_func.number)) | window_start | window_end | ++----------------------------------------+---------------------+---------------------+ +| 2 | 2021-07-01T00:00:00 | 2021-07-01T00:00:01 | ++----------------------------------------+---------------------+---------------------+ select flush_flow('test_numbers_df_func')<=1; @@ -163,14 +163,14 @@ select flush_flow('test_numbers_df_func')<=1; | true | +------------------------------------------------------+ -SELECT col_0, window_start, window_end FROM out_num_cnt_df_func; +SELECT "abs(SUM(numbers_input_df_func.number))", 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 | -+-------+---------------------+---------------------+ ++----------------------------------------+---------------------+---------------------+ +| abs(SUM(numbers_input_df_func.number)) | 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; @@ -197,7 +197,7 @@ Affected Rows: 0 CREATE FLOW test_numbers_df_func SINK TO out_num_cnt_df_func AS -SELECT max(number) - min(number), date_bin(INTERVAL '1 second', ts, '2021-07-01 00:00:00'::TimestampNanosecond) FROM numbers_input_df_func GROUP BY date_bin(INTERVAL '1 second', ts, '2021-07-01 00:00:00'::TimestampNanosecond); +SELECT max(number) - min(number) as maxmin, date_bin(INTERVAL '1 second', ts, '2021-07-01 00:00:00'::TimestampNanosecond) as time_window FROM numbers_input_df_func GROUP BY date_bin(INTERVAL '1 second', ts, '2021-07-01 00:00:00'::TimestampNanosecond); Affected Rows: 0 @@ -224,13 +224,13 @@ select flush_flow('test_numbers_df_func')<=1; | true | +------------------------------------------------------+ -SELECT col_0, col_1 FROM out_num_cnt_df_func; +SELECT maxmin, time_window FROM out_num_cnt_df_func; -+-------+---------------------+ -| col_0 | col_1 | -+-------+---------------------+ -| 2 | 2021-07-01T00:00:00 | -+-------+---------------------+ ++--------+---------------------+ +| maxmin | time_window | ++--------+---------------------+ +| 2 | 2021-07-01T00:00:00 | ++--------+---------------------+ select flush_flow('test_numbers_df_func')<=1; @@ -255,14 +255,14 @@ select flush_flow('test_numbers_df_func')<=1; | true | +------------------------------------------------------+ -SELECT col_0, col_1 FROM out_num_cnt_df_func; +SELECT maxmin, time_window FROM out_num_cnt_df_func; -+-------+---------------------+ -| col_0 | col_1 | -+-------+---------------------+ -| 2 | 2021-07-01T00:00:00 | -| 1 | 2021-07-01T00:00:01 | -+-------+---------------------+ ++--------+---------------------+ +| maxmin | time_window | ++--------+---------------------+ +| 2 | 2021-07-01T00:00:00 | +| 1 | 2021-07-01T00:00:01 | ++--------+---------------------+ DROP FLOW test_numbers_df_func; @@ -289,7 +289,7 @@ Affected Rows: 0 CREATE FLOW test_numbers_df_func SINK TO out_num_cnt AS -SELECT date_trunc('second', ts), sum(number) FROM numbers_input_df_func GROUP BY date_trunc('second', ts); +SELECT date_trunc('second', ts) as time_window, sum(number) as sum_num FROM numbers_input_df_func GROUP BY date_trunc('second', ts); Affected Rows: 0 @@ -316,13 +316,13 @@ select flush_flow('test_numbers_df_func')<=1; | true | +------------------------------------------------------+ -SELECT col_0, col_1 FROM out_num_cnt; +SELECT time_window, sum_num FROM out_num_cnt; -+---------------------+-------+ -| col_0 | col_1 | -+---------------------+-------+ -| 2021-07-01T00:00:00 | 42 | -+---------------------+-------+ ++---------------------+---------+ +| time_window | sum_num | ++---------------------+---------+ +| 2021-07-01T00:00:00 | 42 | ++---------------------+---------+ select flush_flow('test_numbers_df_func')<=1; @@ -347,14 +347,14 @@ select flush_flow('test_numbers_df_func')<=1; | true | +------------------------------------------------------+ -SELECT col_0, col_1 FROM out_num_cnt; +SELECT time_window, sum_num FROM out_num_cnt; -+---------------------+-------+ -| col_0 | col_1 | -+---------------------+-------+ -| 2021-07-01T00:00:00 | 42 | -| 2021-07-01T00:00:01 | 47 | -+---------------------+-------+ ++---------------------+---------+ +| time_window | sum_num | ++---------------------+---------+ +| 2021-07-01T00:00:00 | 42 | +| 2021-07-01T00:00:01 | 47 | ++---------------------+---------+ DROP FLOW test_numbers_df_func; diff --git a/tests/cases/standalone/common/flow/flow_call_df_func.sql b/tests/cases/standalone/common/flow/flow_call_df_func.sql index 45c316ecee9a..eaa1f4c04e6c 100644 --- a/tests/cases/standalone/common/flow/flow_call_df_func.sql +++ b/tests/cases/standalone/common/flow/flow_call_df_func.sql @@ -21,7 +21,7 @@ VALUES -- flush flow to make sure that table is created and data is inserted select flush_flow('test_numbers_df_func')<=1; -SELECT col_0, window_start, window_end FROM out_num_cnt_df_func; +SELECT "SUM(abs(numbers_input_df_func.number))", window_start, window_end FROM out_num_cnt_df_func; select flush_flow('test_numbers_df_func')<=1; @@ -32,7 +32,7 @@ VALUES select flush_flow('test_numbers_df_func')<=1; -SELECT col_0, window_start, window_end FROM out_num_cnt_df_func; +SELECT "SUM(abs(numbers_input_df_func.number))", window_start, window_end FROM out_num_cnt_df_func; DROP FLOW test_numbers_df_func; DROP TABLE numbers_input_df_func; @@ -61,7 +61,7 @@ VALUES -- flush flow to make sure that table is created and data is inserted select flush_flow('test_numbers_df_func')<=1; -SELECT col_0, window_start, window_end FROM out_num_cnt_df_func; +SELECT "abs(SUM(numbers_input_df_func.number))", window_start, window_end FROM out_num_cnt_df_func; select flush_flow('test_numbers_df_func')<=1; @@ -72,7 +72,7 @@ VALUES select flush_flow('test_numbers_df_func')<=1; -SELECT col_0, window_start, window_end FROM out_num_cnt_df_func; +SELECT "abs(SUM(numbers_input_df_func.number))", window_start, window_end FROM out_num_cnt_df_func; DROP FLOW test_numbers_df_func; DROP TABLE numbers_input_df_func; @@ -89,7 +89,7 @@ CREATE TABLE numbers_input_df_func ( CREATE FLOW test_numbers_df_func SINK TO out_num_cnt_df_func AS -SELECT max(number) - min(number), date_bin(INTERVAL '1 second', ts, '2021-07-01 00:00:00'::TimestampNanosecond) FROM numbers_input_df_func GROUP BY date_bin(INTERVAL '1 second', ts, '2021-07-01 00:00:00'::TimestampNanosecond); +SELECT max(number) - min(number) as maxmin, date_bin(INTERVAL '1 second', ts, '2021-07-01 00:00:00'::TimestampNanosecond) as time_window FROM numbers_input_df_func GROUP BY date_bin(INTERVAL '1 second', ts, '2021-07-01 00:00:00'::TimestampNanosecond); select flush_flow('test_numbers_df_func')<=1; @@ -100,7 +100,7 @@ VALUES select flush_flow('test_numbers_df_func')<=1; -SELECT col_0, col_1 FROM out_num_cnt_df_func; +SELECT maxmin, time_window FROM out_num_cnt_df_func; select flush_flow('test_numbers_df_func')<=1; @@ -111,7 +111,7 @@ VALUES select flush_flow('test_numbers_df_func')<=1; -SELECT col_0, col_1 FROM out_num_cnt_df_func; +SELECT maxmin, time_window FROM out_num_cnt_df_func; DROP FLOW test_numbers_df_func; DROP TABLE numbers_input_df_func; @@ -129,7 +129,7 @@ CREATE TABLE numbers_input_df_func ( CREATE FLOW test_numbers_df_func SINK TO out_num_cnt AS -SELECT date_trunc('second', ts), sum(number) FROM numbers_input_df_func GROUP BY date_trunc('second', ts); +SELECT date_trunc('second', ts) as time_window, sum(number) as sum_num FROM numbers_input_df_func GROUP BY date_trunc('second', ts); select flush_flow('test_numbers_df_func')<=1; @@ -140,7 +140,7 @@ VALUES select flush_flow('test_numbers_df_func')<=1; -SELECT col_0, col_1 FROM out_num_cnt; +SELECT time_window, sum_num FROM out_num_cnt; select flush_flow('test_numbers_df_func')<=1; @@ -151,7 +151,7 @@ VALUES select flush_flow('test_numbers_df_func')<=1; -SELECT col_0, col_1 FROM out_num_cnt; +SELECT time_window, sum_num FROM out_num_cnt; DROP FLOW test_numbers_df_func; DROP TABLE numbers_input_df_func;