Table of contents

Sliding Window (Azure Stream Analytics)

Mary McCready|Last Updated: 8/17/2018
|
3 Contributors

When using a sliding window, the system is asked to logically consider all possible windows of a given length. As the number of such windows would be infinite, Azure Stream Analytics instead outputs events only for those points in time when the content of the window actually changes, in other words when an event entered or exits the window.

The following diagram illustrates a stream with a series of events and how they are mapped into sliding windows of 10 seconds.

Stream Analytics 10 second sliding window

Syntax

SLIDINGWINDOW ( timeunit  , windowsize )   
SLIDINGWINDOW ( Duration( timeunit  , windowsize ) )  
Note

The Sliding Window can be used in the above two ways. To allow consistency with the Hopping Window, the Duration function can also be used with all types of windows to specify the window size.

Arguments

timeunit

Is the unit of time for the windowsize. The following table lists all valid timeunit arguments.

TimeunitAbbreviations
daydd, d
hourhh
minutemi, n
secondss, s
millisecondms
microsecondmcs

windowsize

A big integer which describes the size of the window. The windowsize is static and cannot be changed dynamically at runtime.

The maximum size of the window in all cases is 7 days.

Examples

This example finds all toll booths which have served more than 3 vehicles in the last 5 minutes:

SELECT DateAdd(minute,-5,System.TimeStamp) AS WinStartTime, System.TimeStamp AS WinEndTime, TollId, COUNT(*)   
FROM Input TIMESTAMP BY EntryTime  
GROUP BY TollId, SlidingWindow(minute, 5)  
HAVING COUNT(*) > 3  
© 2018 Microsoft