Skip to content

Instantly share code, notes, and snippets.

@vlcanunal
Created February 4, 2021 10:52
Show Gist options
  • Save vlcanunal/a6d9b393e290b0f4705773c09f890484 to your computer and use it in GitHub Desktop.
Save vlcanunal/a6d9b393e290b0f4705773c09f890484 to your computer and use it in GitHub Desktop.
Stream Aggregation
create table city_analytics_order_realtime_black_friday
with (KAFKA_TOPIC='city_analytics.order_realtime_black_friday',PARTITIONS=1,VALUE_FORMAT='JSON') as
select timestamptostring(orderDate, 'yyyy-MM') as orderDate,
cityId ,
SUM(cartCount) as totalCount,
SUM(productPrice) as totalPrice
from city_analytics_order_realtime_full where timestamptostring(orderDate, 'yyyy-MM-dd') >= '2020–11–27' and timestamptostring(orderDate, 'yyyy-MM-dd') <= '2020–11–30'
group by timestamptostring(orderDate, 'yyyy-MM'), cityId
EMIT CHANGES;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment