Data structure: {sensorId: 1, temp: 20, timestamp: 1525119377241}
Window Query:
SELECT
System.Timestamp as WindowEnd,
sensorId,
AVG(temp) AS avgTemp,
FROM
SensorStream TIMESTAMP BY timestamp
GROUP BY
sensorId,
SlidingWindow(second, 30)
I would like to calculate in realtime the Slope between the actual avgTemp and the avgTemp 30s before.
Using a tumbling window
would work by using LAG(avgTemp, 1)
but this would only output every 30s.
TL;DR: I would like to calculate the slope in realtime everytime a new avgTemp is calculated by the sliding window.