Skip to content

Instantly share code, notes, and snippets.

@kleong
Created July 30, 2019 20:27
Show Gist options
  • Save kleong/0dbb6cc09ecdd528f1d1dc6f85c9babc to your computer and use it in GitHub Desktop.
Save kleong/0dbb6cc09ecdd528f1d1dc6f85c9babc to your computer and use it in GitHub Desktop.
WITH lastest_hashtags AS
(SELECT lower(ht.text) AS hashtag
FROM "twitter-kinesis-demo" t,
unnest(t.extended_tweet.entities.hashtags) ht
WHERE CAST(t.timestamp_ms AS INT) > UNIX_MILLIS(current_timestamp() - hours(1)))
SELECT count(hashtag) AS tweet_count,
hashtag
FROM latest_hashtags
GROUP BY hashtag
ORDER BY tweet_count DESC
LIMIT 10;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment