You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the following input data (illustrated above):
29
+
30
+
|Stamp|CreatedAt|TimeZone|
31
+
|-|-|-|
32
+
|1|2021-10-26T10:15:01|PST|
33
+
|5|2021-10-26T10:15:03|PST|
34
+
|4|2021-10-26T10:15:06|PST|
35
+
|...|...|...|
36
+
37
+
The following query:
38
+
39
+
```SQL
40
+
SELECTSystem.Timestamp() as WindowEndTime, TimeZone, COUNT(*) AS Count
41
+
FROM TwitterStream TIMESTAMP BY CreatedAt
42
+
GROUP BY TimeZone, TumblingWindow(second,10)
43
+
```
44
+
45
+
Will return:
46
+
47
+
|WindowEndTime|TimeZone|Count|
48
+
|-|-|-|
49
+
|2021-10-26T10:15:10|PST|5|
50
+
|2021-10-26T10:15:20|PST|2|
51
+
|2021-10-26T10:15:30|PST|4|
52
+
53
+
28
54
## Hopping window
29
55
30
56
[**Hopping**](/stream-analytics-query/hopping-window-azure-stream-analytics) window functions hop forward in time by a fixed period. It may be easy to think of them as Tumbling windows that can overlap and be emitted more often than the window size. Events can belong to more than one Hopping window result set. To make a Hopping window the same as a Tumbling window, specify the hop size to be the same as the window size.
With the following input data (illustrated above):
61
+
62
+
|Stamp|CreatedAt|Topic|
63
+
|-|-|-|
64
+
|1|2021-10-26T10:15:01|Streaming|
65
+
|5|2021-10-26T10:15:03|Streaming|
66
+
|4|2021-10-26T10:15:06|Streaming|
67
+
|...|...|...|
68
+
69
+
The following query:
70
+
71
+
```SQL
72
+
SELECTSystem.Timestamp() as WindowEndTime, Topic, COUNT(*) AS Count
73
+
FROM TwitterStream TIMESTAMP BY CreatedAt
74
+
GROUP BY Topic, HoppingWindow(second,10,5)
75
+
```
76
+
77
+
Will return:
78
+
79
+
|WindowEndTime|Topic|Count|
80
+
|-|-|-|
81
+
|2021-10-26T10:15:10|Streaming|5|
82
+
|2021-10-26T10:15:15|Streaming|3|
83
+
|2021-10-26T10:15:20|Streaming|2|
84
+
|2021-10-26T10:15:25|Streaming|4|
85
+
|2021-10-26T10:15:30|Streaming|4|
86
+
87
+
34
88
## Sliding window
35
89
36
90
[**Sliding**](/stream-analytics-query/sliding-window-azure-stream-analytics) windows, unlike Tumbling or Hopping windows, output events only for points in time when the content of the window actually changes. In other words, when an event enters or exits the window. So, every window has at least one event. Similar to Hopping windows, events can belong to more than one sliding window.
37
91
38
92

39
93
94
+
With the following input data (illustrated above):
95
+
96
+
|Stamp|CreatedAt|Topic|
97
+
|-|-|-|
98
+
|1|2021-10-26T10:15:10|Streaming|
99
+
|5|2021-10-26T10:15:12|Streaming|
100
+
|9|2021-10-26T10:15:15|Streaming|
101
+
|7|2021-10-26T10:15:15|Streaming|
102
+
|8|2021-10-26T10:15:27|Streaming|
103
+
104
+
The following query:
105
+
106
+
```SQL
107
+
SELECTSystem.Timestamp() as WindowEndTime, Topic, COUNT(*) AS Count
108
+
FROM TwitterStream TIMESTAMP BY CreatedAt
109
+
GROUP BY Topic, SlidingWindow(second,10)
110
+
HAVINGCOUNT(*) >=3
111
+
```
112
+
113
+
Will return:
114
+
115
+
|WindowEndTime|Topic|Count|
116
+
|-|-|-|
117
+
|2021-10-26T10:15:15|Streaming|4|
118
+
|2021-10-26T10:15:20|Streaming|3|
119
+
40
120
## Session window
41
121
42
122
[**Session**](/stream-analytics-query/session-window-azure-stream-analytics) window functions group events that arrive at similar times, filtering out periods of time where there is no data. It has three main parameters: timeout, maximum duration, and partitioning key (optional).
@@ -49,11 +129,63 @@ If events keep occurring within the specified timeout, the session window will k
49
129
50
130
When a partition key is provided, the events are grouped together by the key and session window is applied to each group independently. This partitioning is useful for cases where you need different session windows for different users or devices.
51
131
132
+
With the following input data (illustrated above):
133
+
134
+
|Stamp|CreatedAt|Topic|
135
+
|-|-|-|
136
+
|1|2021-10-26T10:15:01|Streaming|
137
+
|2|2021-10-26T10:15:04|Streaming|
138
+
|3|2021-10-26T10:15:13|Streaming|
139
+
|...|...|...|
140
+
141
+
The following query:
142
+
143
+
```SQL
144
+
SELECTSystem.Timestamp() as WindowEndTime, Topic, COUNT(*) AS Count
145
+
FROM TwitterStream TIMESTAMP BY CreatedAt
146
+
GROUP BY Topic, SessionWindow(second,5,10)
147
+
```
148
+
149
+
Will return:
150
+
151
+
|WindowEndTime|Topic|Count|
152
+
|-|-|-|
153
+
|2021-10-26T10:15:09|Streaming|2|
154
+
|2021-10-26T10:15:24|Streaming|4|
155
+
|2021-10-26T10:15:31|Streaming|2|
156
+
|2021-10-26T10:15:39|Streaming|1|
157
+
52
158
## Snapshot window
53
159
54
160
[**Snapshot**](/stream-analytics-query/snapshot-window-azure-stream-analytics) windows group events that have the same timestamp. Unlike other windowing types, which require a specific window function (such as [SessionWindow()](/stream-analytics-query/session-window-azure-stream-analytics), you can apply a snapshot window by adding System.Timestamp() to the GROUP BY clause.
0 commit comments