Skip to content

Instantly share code, notes, and snippets.

@confluentgist
Forked from miguno/aggregation.sql
Created January 9, 2020 22:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save confluentgist/c65019bf7607fbb988f0df38866adb77 to your computer and use it in GitHub Desktop.
Save confluentgist/c65019bf7607fbb988f0df38866adb77 to your computer and use it in GitHub Desktop.
ksqlDB example: Continuously aggregating a stream into a table with a push query
-- Continuously aggregating a stream into a table with a ksqlDB push query.
CREATE STREAM locationUpdatesStream ...;
CREATE TABLE locationsPerUser AS
SELECT username, COUNT(*)
FROM locationUpdatesStream
GROUP BY username
EMIT CHANGES;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment