Skip to content

Commit

Permalink
support session and hop window (#36)
Browse files Browse the repository at this point in the history
* feat(nested join)support nested join

* maintain(rsqldb-server) optimize the server

* add purchaser_dim.sql

* support dim join

* remove dim with rocketmq

* remove password and userName of db

* move file

* filter sql without VIEW table

* remove VIEW talbe

* support tumble window

* fix(doc) start in local

* fix(doc) start in local

* fix(doc) modif README.md

* fix(doc) modif README.md

* fix(doc) modif README.md

* support hop and session
  • Loading branch information
ni-ze authored Sep 7, 2022
1 parent b621310 commit 5d59417
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 0 deletions.
35 changes: 35 additions & 0 deletions rsqldb-disk/client/window/hop_eventTime.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
CREATE TABLE user_clicks
(
username VARCHAR,
click_url VARCHAR,
ts TIMESTAMP,
WATERMARK wk FOR ts AS WITHOFFSET (ts, 2000)--为rowtime定义Watermark。
) WITH (
type = 'rocketmq',
topic = 'user_clicks',
groupName = 'user_clicks',
namesrvAddr = '127.0.0.1:9876',
isJsonData = 'true',
msgIsJsonArray = 'false'
);


CREATE TABLE hop_output
(
window_start TIMESTAMP,
window_end TIMESTAMP,
username VARCHAR,
clicks BIGINT
) WITH (
type = 'print'
);


INSERT INTO hop_output
SELECT
HOP_START (ts, INTERVAL '30' SECOND, INTERVAL '1' MINUTE) as window_start,
HOP_END (ts, INTERVAL '30' SECOND, INTERVAL '1' MINUTE) as window_end,
username as username,
COUNT(click_url) as clicks
FROM user_clicks
GROUP BY HOP (ts, INTERVAL '30' SECOND, INTERVAL '1' MINUTE), username;
33 changes: 33 additions & 0 deletions rsqldb-disk/client/window/hop_processTime.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
CREATE TABLE window_test
(
username VARCHAR,
click_url VARCHAR,
ts as PROCTIME()
) WITH (
type = 'rocketmq',
topic = 'window_test',
groupName = 'window_test',
namesrvAddr = '127.0.0.1:9876',
isJsonData = 'true',
msgIsJsonArray = 'false'
);

CREATE TABLE hop_output
(
window_start TIMESTAMP,
window_end TIMESTAMP,
username VARCHAR,
clicks BIGINT
) with (
type='print'
);

INSERT INTO hop_output
SELECT
HOP_START (ts, INTERVAL '30' SECOND, INTERVAL '1' MINUTE) as window_start,
HOP_END (ts, INTERVAL '30' SECOND, INTERVAL '1' MINUTE) as window_end,
username as username,
COUNT(click_url) as clicks
FROM window_test
GROUP BY HOP (ts, INTERVAL '30' SECOND, INTERVAL '1' MINUTE), username;

34 changes: 34 additions & 0 deletions rsqldb-disk/client/window/session_eventTime.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
CREATE TABLE user_clicks
(
username VARCHAR,
click_url VARCHAR,
ts TIMESTAMP,
WATERMARK wk FOR ts as withOffset(ts, 2000) --为rowtime定义Watermark。
) WITH (
type = 'rocketmq',
topic = 'user_clicks',
groupName = 'user_clicks',
namesrvAddr = '127.0.0.1:9876',
isJsonData = 'true',
msgIsJsonArray = 'false'
);


CREATE TABLE task_sink
(
window_start TIMESTAMP,
window_end TIMESTAMP,
username VARCHAR,
clicks BIGINT
) WITH (
type = 'print'
);

INSERT INTO task_sink
SELECT
SESSION_START(ts, INTERVAL '30' SECOND) as window_start,
SESSION_END(ts, INTERVAL '30' SECOND) as window_end,
username as username,
COUNT(click_url) as clicks
FROM user_clicks
GROUP BY SESSION(ts, INTERVAL '30' SECOND), username;
32 changes: 32 additions & 0 deletions rsqldb-disk/client/window/session_processTime.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
CREATE TABLE window_test
(
username VARCHAR,
click_url VARCHAR,
ts as PROCTIME()
) WITH (
type = 'rocketmq',
topic = 'window_test',
groupName = 'window_test',
namesrvAddr = '127.0.0.1:9876',
isJsonData = 'true',
msgIsJsonArray = 'false'
);

CREATE TABLE session_output
(
window_start TIMESTAMP,
window_end TIMESTAMP,
username VARCHAR,
clicks BIGINT
) with (
type='print'
);

INSERT INTO session_output
SELECT
SESSION_START(ts, INTERVAL '30' SECOND) as window_start,
SESSION_END(ts, INTERVAL '30' SECOND) as window_end,
username as username,
COUNT(click_url) as clicks
FROM window_test
GROUP BY SESSION(ts, INTERVAL '30' SECOND), username;

0 comments on commit 5d59417

Please sign in to comment.