From scenario: Topics are considered to be trending if they generate many mentions in a specific country during a 15-minute time frame.
Box 1: TimeStamp -
Azure Stream Analytics (ASA) is a cloud service that enables real-time processing over streams of data flowing in from devices, sensors, websites and other live systems. The stream-processing logic in ASA is expressed in a SQL-like query language with some added extensions such as windowing for performing temporal calculations.
ASA is a temporal system, so every event that flows through it has a timestamp. A timestamp is assigned automatically based on the event's arrival time to the input source but you can also access a timestamp in your event payload explicitly using TIMESTAMP BY:
SELECT * FROM SensorReadings TIMESTAMP BY time
Box 2: GROUP BY -
Example: Generate an output event if the temperature is above 75 for a total of 5 seconds
SELECT sensorId, MIN(temp) as temp
FROM SensorReadings -
TIMESTAMP BY time -
GROUP BY sensorId, SlidingWindow(second, 5)
HAVING MIN(temp) > 75 -
Box 3: SlidingWindow -
Windowing is a core requirement for stream processing applications to perform set-based operations like counts or aggregations over events that arrive within a specified period of time. ASA supports three types of windows: Tumbling, Hopping, and Sliding.
With a Sliding Window, the system is asked to logically consider all possible windows of a given length and output events for cases when the content of the window actually changes that is, when an event entered or existed the window.
Reference: https://blogs.technet.microsoft.com/machinelearning/2015/06/01/the-azure-stream-analytics-query-language/
