Skip to content

Commit

Permalink
test: sqlness tests added back for flow
Browse files Browse the repository at this point in the history
  • Loading branch information
discord9 committed Jul 24, 2024
1 parent c9871fa commit 2ff9220
Show file tree
Hide file tree
Showing 6 changed files with 769 additions and 51 deletions.
134 changes: 134 additions & 0 deletions tests/cases/standalone/common/flow/flow_basic.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
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?
select flush_flow('test_numbers_basic')*0;

+---------------------------------------------------+
| flush_flow(Utf8("test_numbers_basic")) * Int64(0) |
+---------------------------------------------------+
| 0 |
+---------------------------------------------------+

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')*0;

+---------------------------------------------------+
| flush_flow(Utf8("test_numbers_basic")) * Int64(0) |
+---------------------------------------------------+
| 0 |
+---------------------------------------------------+

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')*0;

+---------------------------------------------------+
| flush_flow(Utf8("test_numbers_basic")) * Int64(0) |
+---------------------------------------------------+
| 0 |
+---------------------------------------------------+

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')*0;

+---------------------------------------------------+
| flush_flow(Utf8("test_numbers_basic")) * Int64(0) |
+---------------------------------------------------+
| 0 |
+---------------------------------------------------+

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

60 changes: 60 additions & 0 deletions tests/cases/standalone/common/flow/flow_basic.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
CREATE TABLE numbers_input_basic (
number INT,
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY(number),
TIME INDEX(ts)
);

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');

-- TODO(discord9): confirm if it's necessary to flush flow here?
select flush_flow('test_numbers_basic')*0;

INSERT INTO numbers_input_basic
VALUES
(20, "2021-07-01 00:00:00.200"),
(22, "2021-07-01 00:00:00.600");

select flush_flow('test_numbers_basic')*0;

SELECT col_0, window_start, window_end FROM out_num_cnt_basic;

select flush_flow('test_numbers_basic')*0;

INSERT INTO numbers_input_basic
VALUES
(23,"2021-07-01 00:00:01.000"),
(24,"2021-07-01 00:00:01.500");

select flush_flow('test_numbers_basic')*0;

SELECT col_0, window_start, window_end FROM out_num_cnt_basic;

DROP FLOW test_numbers_basic;
DROP TABLE numbers_input_basic;
DROP TABLE out_num_cnt_basic;

-- test interprete interval

CREATE TABLE numbers_input_basic (
number INT,
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY(number),
TIME INDEX(ts)
);
create table out_num_cnt_basic (
number INT,
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP TIME INDEX);

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;

SHOW CREATE FLOW filter_numbers_basic;

drop flow filter_numbers_basic;

drop table out_num_cnt_basic;

drop table numbers_input_basic;
Loading

0 comments on commit 2ff9220

Please sign in to comment.