Last active
August 31, 2021 09:04
-
-
Save morsapaes/78e38ba5e5d913f2845a5f1341c0ba88 to your computer and use it in GitHub Desktop.
Analyzing Twitch streams with Materialize: what gaming streams started in the last 15 min?
This file contains hidden or 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
CREATE MATERIALIZED VIEW mv_stream_15min AS | |
SELECT title, | |
user_name, | |
game_name, | |
started_at | |
FROM v_twitch_stream | |
WHERE game_id IS NOT NULL | |
--Use temporal filters to filter events with | |
--a sliding window of 15 minutes (900000 miliseconds) | |
AND (mz_logical_timestamp() >= (extract('epoch' from started_at)*1000)::bigint | |
AND mz_logical_timestamp() < (extract('epoch' from started_at)*1000)::bigint + 900000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment