TTL设置
最佳实践:显示要用请配置State TTL Config,在精确性和大小之间的权衡。
streamQueryConfig.withIdleStateRetentionTime(Time.day(1), Time.day(2))
Group Windows
TUMBLE(t, INTERVAL '2' HOUR)
HOP(t, INTERVAL '2' HOUR, INTERVAL '1' HOUR)
SESSION(t, INTERVAL '30' MINUTE)
SELECT user, TUMBLE_END(ctime, INTERVAL '1' HOURS) AS end_time, COUNT(url) AS cnt
FROM click GROUP BY user TUMBLE(ctime, INTERVAL '1' HOURS);
Group Aggregation
每来一条都更新一次结果。后面最好接幂等Sink,MySQL和HBase这类。要不然会出现一大堆历史数据(可能根本不需要)。
SELECT user, COUNT(url) as cnt FROM click GROUP BY user;
INSERT INTO sink
SELECT * FROM source;
Over Window
https://help.aliyun.com/document_detail/62514.html?spm=a2c4g.11186623.6.765.613260bcR4TzE4