Tumbling Window (Azure Stream Analytics)
Updated: April 22, 2016
Applies To: Azure
Tumbling windows are a series of fixed-sized, non-overlapping and contiguous time intervals. The following diagram illustrates a stream with a series of events and how they are mapped into 5-second tumbling windows.

Syntax
TUMBLINGWINDOW ( timeunit , windowsize, [offsetsize] ) TUMBLINGWINDOW ( Duration( timeunit , windowsize ), [Offset(timeunit , offsetsize)] )
|
timeunit
Is the unit of time for the windowsize. The following table lists all valid timeunit arguments.
| Timeunit | Abbreviations |
|---|---|
| day | dd, d |
| hour | hh |
| minute | mi, n |
| second | ss, s |
| millisecond | ms |
| microsecond | mcs |
windowsize
A big integer which describes the size of the window.
The maximum size of the window is 7 days.
offsetsize
By default, tumbling windows are inclusive in the end of the window and exclusive in the beginning – for example 12:00 PM – 1:00 PM window will include events that happened exactly at 1:00 PM, but will not include events that happened at 12:00PM (these events will be part of 11:00 AM – 12:00 PM window).
The Offset parameter can be used to change this behavior and include the events in the beginning of the window and exclude the ones that happened in the end.
SELECT System.TimeStamp AS WindowEnd, TollId, COUNT(*) FROM Input TIMESTAMP BY EntryTime GROUP BY TollId, TumblingWindow(Duration(hour, 1), Offset(millisecond, -1))