Skip to content

Instantly share code, notes, and snippets.

@nfarah86
Created May 2, 2022 19:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nfarah86/f0c1f1a7ebdf1eee58a2b4cbd3c68a00 to your computer and use it in GitHub Desktop.
Save nfarah86/f0c1f1a7ebdf1eee58a2b4cbd3c68a00 to your computer and use it in GitHub Desktop.
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