Azure Stream Analytics - Windowing Functions
Azure Stream Analytics - Windowing Functions
Tumbling Window
Splits data into distinct, non-overlapping, adjoining time intervals.
An event can belong to only one tumbling window.
Useful for operations where data in each window is independent.
sql
TumblingWindow(timeUnit, windowSize)
timeUnit: Unit of time (e.g., second, minute, hour).
windowSize: The size of the window in the specified time unit.
EXAMPLE: GROUP BY TumblingWindow(second,10)
Hopping Window
Moves forward in fixed time increments, potentially smaller than the window size, resulting in overlapping windows.
An event can belong to multiple hopping windows.
Can be used to get frequent insights while still considering a broader time frame.
HoppingWindow(timeUnit, windowSize, hopSize)
timeUnit: Unit of time.
windowSize: The size of the window.
hopSize: The time period by which the window moves forward.
EXAMPLE: GROUP BY HoppingWindow(second,10,5)
Sliding Window
Produces an output every time the content of the window changes, i.e., when an event enters or exits the window.
Ensures that every output window has at least one event.
sql
SlidingWindow(timeUnit, windowSize)
timeUnit: Unit of time.
windowSize: The size of the window.
EXAMPLE: GROUP BY SlidingWindow(second,10)
Session Window
Groups events that are close in time while filtering out periods with no data.
Session starts with the first event and extends with consecutive events if they are within a specified timeout.
sql
SessionWindow(timeUnit, timeout, maxDuration)
timeUnit: Unit of time.
timeout: Time after which, if no new data arrives, the session is considered closed.
maxDuration: Maximum length of a session.
EXAMPLE: GROUP BY SessionWindow(second,5,10)
Snapshot Window
Groups events with the same timestamp.
There's no specific function. Instead, you use System.Timestamp() in the GROUP BY clause.
EXAMPLE: GROUP BY System.Timestamp()
source: https://learn.microsoft.com/en-us/azure/stream-analytics/stream-analytics-window-functions