user185981
user185981

Reputation: 19

Azure Stream Analytics :Tumbling Window

I have 2 questions:

1) How Tumbling Window Works ?

So suppose I have events coming continuously I do Tumbling(hour ,1)
Then Stream Analytics will wait for 1 hour and group them and give me 1 record

or as soon as event comes , it will give me record ,grouping data for last 1 hour?

2) In my scenario ,I have payment coming continuously,I need to have sum of all Amount for that day,every time when Transaction Come it should give me SUM.

So Suppose below are my transaction data

Testdata

So as we can see in the image

Upvotes: 1

Views: 846

Answers (1)

TheTurkishDeveloper
TheTurkishDeveloper

Reputation: 187

For question #1, SA will wait the 1 hour and then group and give you one record as output.

Windowing Functions (Azure Stream Analytics)

Every window operation outputs event at the end of the window. The windows of Azure Stream Analytics are opened at the window start time and closed at the window end time. For example, if you have a 5 minute window from 12:00 AM to 12:05 AM all events with timestamp greater than 12:00 AM and up to timestamp 12:05 AM inclusive will be included within this window. The output of the window will be a single event based on the aggregate function used with a timestamp equal to the window end time.

For question #2, I believe you can use a Hopping Window and define your duration for the last 1 day (86400 seconds), like so:

SELECT Amount, SUM(Amount) as TotalTransactions 
FROM <YourSAInput> TIMESTAMP BY TransactionDate
GROUP BY Amount, HoppingWindow(seconds, 86400, 1)

Hopping Window (Azure Stream Analytics)

A hopping window specification consist of three parameters: the timeunit, the windowsize (how long each window lasts) and the hopsize (by how much each window moves forward relative to the previous one).

Hope this helps.

Upvotes: 1

Related Questions