Skip to content

Instantly share code, notes, and snippets.

@stephendeyoung
Created August 25, 2017 16:44
Show Gist options
  • Save stephendeyoung/5d87c5ac1bdfca436eb1076359a6034d to your computer and use it in GitHub Desktop.
Save stephendeyoung/5d87c5ac1bdfca436eb1076359a6034d to your computer and use it in GitHub Desktop.
CREATE OR REPLACE STREAM "DESTINATION_SQL_STREAM" (
entity_id VARCHAR(64),
avg_power DOUBLE);
CREATE OR REPLACE PUMP "STREAM_PUMP" AS INSERT INTO "DESTINATION_SQL_STREAM"
SELECT STREAM
entity_id,
AVG(active_power) OVER secs_window
FROM "SOURCE_SQL_STREAM_001"
WINDOW
secs_window AS (PARTITION BY entity_id RANGE INTERVAL '5' SECOND PRECEDING)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment