Created
May 2, 2022 19:07
-
-
Save nfarah86/f0c1f1a7ebdf1eee58a2b4cbd3c68a00 to your computer and use it in GitHub Desktop.
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
with _data as ( | |
SELECT | |
tweets, | |
event_date_hour_str, | |
event_date_hour, | |
id, | |
name | |
FROM | |
officehours."twitter-firehose-rollup" t hint(access_path=column_scan) | |
where | |
t.event_date_hour > CURRENT_TIMESTAMP() - DAYS(1) | |
order by | |
event_date_hour desc | |
), | |
_intermediate as ( | |
select | |
array_agg(event_date_hour_str) _keys, | |
array_agg(tweets) _values, | |
id, | |
arbitrary(name) name | |
from | |
_data | |
group by | |
_data.id | |
) | |
select | |
object(_keys, _values) as timeseries, | |
id, | |
name | |
from | |
_intermediate | |
order by length(_keys) desc | |
Limit 100 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment