Skip to content

Instantly share code, notes, and snippets.

@morsapaes
Last active August 31, 2021 09:04
Show Gist options
  • Save morsapaes/78e38ba5e5d913f2845a5f1341c0ba88 to your computer and use it in GitHub Desktop.
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?
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