Skip to content

Commit 2eaea50

Browse files
test(stream): add join and temporal_filter state-cleaning test (risingwavelabs#8596)
Signed-off-by: TennyZhuang <[email protected]> Co-authored-by: Yuhao Su <[email protected]>
1 parent a4bd877 commit 2eaea50

File tree

2 files changed

+99
-0
lines changed

2 files changed

+99
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
[[test]]
2+
name = "window_hash_join"
3+
init_sqls = [
4+
"""
5+
CREATE TABLE orders (
6+
order_id INTEGER,
7+
user_id INTEGER,
8+
amount INTEGER,
9+
created_at TIMESTAMP,
10+
WATERMARK FOR created_at AS created_at - interval '9' second
11+
) APPEND ONLY WITH (
12+
connector = 'datagen',
13+
rows_per_second = 100,
14+
datagen.split.num = 16,
15+
fields.created_at.max_past_mode = 'relative',
16+
fields.created_at.max_past = '10s',
17+
fields.order_id.kind = 'sequence',
18+
fields.order_id.start = 0,
19+
fields.user_id.min = 0,
20+
fields.user_id.max = 20,
21+
fields.amount.min = 0,
22+
fields.amount.max = 20,
23+
);
24+
""",
25+
"""
26+
CREATE TABLE clicks (
27+
click_id INTEGER,
28+
user_id INTEGER,
29+
created_at TIMESTAMP,
30+
WATERMARK FOR created_at AS created_at - interval '9' second
31+
) APPEND ONLY WITH (
32+
connector = 'datagen',
33+
rows_per_second = 200,
34+
datagen.split.num = 16,
35+
fields.created_at.max_past_mode = 'relative',
36+
fields.created_at.max_past = '10s',
37+
fields.click_id.kind = 'sequence',
38+
fields.click_id.start = 0,
39+
fields.user_id.min = 0,
40+
fields.user_id.max = 20,
41+
);
42+
""",
43+
"""
44+
CREATE MATERIALIZED VIEW mv_tumble_join AS
45+
SELECT clicks.window_start, clicks.user_id AS user_id
46+
FROM
47+
TUMBLE(orders, created_at, INTERVAL '1' second) AS orders
48+
JOIN TUMBLE(clicks, created_at, INTERVAL '1' second) AS clicks
49+
ON
50+
orders.window_start = clicks.window_start AND
51+
clicks.user_id = orders.user_id;
52+
""",
53+
]
54+
bound_tables = { pattern = '__internal_mv_tumble_join_\d+_hashjoin(left|right)_\d+', limit = 300 }
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
[[test]]
2+
name = "temporal_filter"
3+
init_sqls = [
4+
"""
5+
CREATE TABLE clicks (
6+
click_id INTEGER,
7+
user_id INTEGER,
8+
created_at TIMESTAMP,
9+
WATERMARK FOR created_at AS created_at - interval '9' second
10+
) APPEND ONLY WITH (
11+
connector = 'datagen',
12+
rows_per_second = 200,
13+
datagen.split.num = 16,
14+
fields.created_at.max_past_mode = 'relative',
15+
fields.created_at.max_past = '10s',
16+
fields.click_id.kind = 'sequence',
17+
fields.click_id.start = 0,
18+
fields.user_id.min = 0,
19+
fields.user_id.max = 20,
20+
);
21+
""",
22+
# Used by now()
23+
"""
24+
SET TIME ZONE LOCAL;
25+
""",
26+
"""
27+
CREATE MATERIALIZED VIEW clicks_10s AS
28+
SELECT * FROM clicks WHERE created_at > now() - INTERVAL '10' second;
29+
""",
30+
"""
31+
CREATE MATERIALIZED VIEW clicks_20s AS
32+
SELECT * FROM clicks WHERE created_at > now() - INTERVAL '20' second;
33+
""",
34+
"""
35+
CREATE MATERIALIZED VIEW clicks_30s AS
36+
SELECT * FROM clicks WHERE created_at > now() - INTERVAL '30' second;
37+
""",
38+
]
39+
bound_tables = [
40+
{ pattern = '__internal_clicks_10s_\d+_dynamicfilterleft_\d+', limit = 300 },
41+
{ pattern = '__internal_clicks_20s_\d+_dynamicfilterleft_\d+', limit = 600 },
42+
{ pattern = '__internal_clicks_30s_\d+_dynamicfilterleft_\d+', limit = 900 },
43+
# Right table should always only contains 1 record.
44+
{ pattern = '__internal_clicks_\d+s_\d+_dynamicfilterright_\d+', limit = 1 },
45+
]

0 commit comments

Comments
 (0)