-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support session and hop window (#36)
* 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
Showing
4 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |