Skip to content

Commit 8d1dae6

Browse files
Addressing comments second iteration
Addressing comments from Mary
1 parent c989244 commit 8d1dae6

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

articles/stream-analytics/stream-analytics-stream-analytics-query-patterns.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ The query design can express simple pass-through logic to move event data from o
1717

1818
This article outlines solutions to several common query patterns based on real-world scenarios.
1919

20-
## Data Formats
20+
## Supported Data Formats
2121

2222
Azure Stream Analytics supports processing events in CSV, JSON and Avro data formats.
2323

@@ -339,7 +339,7 @@ For more information, refer to [**COUNT** aggregate function](/stream-analytics-
339339

340340
## Calculation over past events
341341

342-
The **LAG** function, can be used to look into past events within a time window, this allow past values to be compared against the current event. For example, the current car *Make* can be outputted if it is different from the last car that went through the toll.
342+
The **LAG** function can be used to look at past events within a time window and compare them against the current event. For example, the current car make can be outputted if it is different from the last car that went through the toll.
343343

344344
**Input**:
345345

@@ -370,7 +370,7 @@ Use **LAG** to peek into the input stream one event back, retrieving the *Make*
370370

371371
For more information, refer to [**LAG**](/stream-analytics-query/lag-azure-stream-analytics).
372372

373-
## The first event in a window
373+
## Retrieve the first event in a window
374374

375375
**IsFirst** can be used to retrieve the first event in a time window. For example, outputting the first car information at every 10-minute interval.
376376

@@ -433,9 +433,9 @@ WHERE
433433

434434
For more information, refer to [**IsFirst**](/stream-analytics-query/isfirst-azure-stream-analytics).
435435

436-
## The last event in a window
436+
## Return the last event in a window
437437

438-
As events are consumed by the system in real time, there is no function that can determine if an event will be the last one to arrive for that window of time. To achieve this, the input stream needs to be joined with another where the time of an event is the maximum time for all events at that window.
438+
As events are consumed by the system in real-time, there is no function that can determine if an event will be the last one to arrive for that window of time. To achieve this, the input stream needs to be joined with another where the time of an event is the maximum time for all events at that window.
439439

440440
**Input**:
441441

@@ -482,12 +482,12 @@ FROM
482482

483483
The first step on the query finds the maximum time stamp in 10-minute windows, that is the time stamp of the last event for that window. The second step joins the results of the first query with the original stream to find the event that match the last time stamps in each window.
484484

485-
**DATEDIFF** is a date specific function that compares and returns the time different between two DateTime fields, for more information, refer to [date functions](https://docs.microsoft.com/en-us/stream-analytics-query/date-and-time-functions-azure-stream-analytics).
485+
**DATEDIFF** is a date-specific function that compares and returns the time difference between two DateTime fields, for more information, refer to [date functions](https://docs.microsoft.com/stream-analytics-query/date-and-time-functions-azure-stream-analytics).
486486

487487
For more information on joining streams, refer to [**JOIN**](/stream-analytics-query/join-azure-stream-analytics).
488488

489489

490-
## Correlating events in a stream
490+
## Correlate events in a stream
491491

492492
Correlating events in the same stream can be done by looking at past events using the **LAG** function. For example, an output can be generated every time two consecutive cars from the same *Make* go through the toll for the last 90 seconds.
493493

@@ -525,7 +525,7 @@ The **LAG** function can look into the input stream one event back and retrieve
525525

526526
For more information, refer to [LAG](/stream-analytics-query/lag-azure-stream-analytics).
527527

528-
## Detecting the duration between events
528+
## Detect the duration between events
529529

530530
The duration of an event can be computed by looking at the last Start event once an End event is received. This query can be useful to determine the time a user spends on a page or a feature.
531531

@@ -557,11 +557,11 @@ WHERE
557557
Event = 'end'
558558
```
559559

560-
The **LAST** function can be used to retrieve the last event within a specific condition. In this example, the condition is an event of type Start, partitioning the search by **PARTITION BY** [user] and Feature. This way, every user and feature will be treated independently when searching for the Start event. **LIMIT DURATION** limits the search back in time to 1 hour between the End and Start events.
560+
The **LAST** function can be used to retrieve the last event within a specific condition. In this example, the condition is an event of type Start, partitioning the search by **PARTITION BY** user and feature. This way, every user and feature is treated independently when searching for the Start event. **LIMIT DURATION** limits the search back in time to 1 hour between the End and Start events.
561561

562-
## Detecting the duration of a condition
562+
## Detect the duration of a condition
563563

564-
A certain condition can span through multiple events, **LAG** function can also be used to identify the duration of that condition. For example, suppose that a bug resulted in all cars having an incorrect weight (above 20,000 pounds), and the duration of that bug must be computed.
564+
For conditions that span through multiple events the **LAG** function can be used to identify the duration of that condition. For example, suppose that a bug resulted in all cars having an incorrect weight (above 20,000 pounds), and the duration of that bug must be computed.
565565

566566
**Input**:
567567

@@ -602,11 +602,11 @@ WHERE
602602
[weight] < 20000
603603
AND previous_weight > 20000
604604
```
605-
The first **SELECT** statement correlates the current weight measurement with the previous measurement, projecting it together with the current one. The second **SELECT** looks back to the last event where the *previous_weight* is less than 20000, where the current weight is smaller than 20000 and the *previous_weight* of the current event was bigger than 20000.
605+
The first **SELECT** statement correlates the current weight measurement with the previous measurement, projecting it together with the current measurement. The second **SELECT** looks back to the last event where the *previous_weight* is less than 20000, where the current weight is smaller than 20000 and the *previous_weight* of the current event was bigger than 20000.
606606

607-
Sounds complicated but it is simple, the *End_fault* is the current non-faulty event where the previous event was faulty, and the *Start_fault* is the last non-faulty event before that.
607+
The End_fault is the current non-faulty event where the previous event was faulty, and the Start_fault is the last non-faulty event before that.
608608

609-
## Periodically outputting values
609+
## Periodically output values
610610

611611
In case of irregular or missing events, a regular interval output can be generated from a more sparse data input. For example, generate an event every 5 seconds that reports the most recently seen data point.
612612

@@ -652,9 +652,9 @@ This query generates events every 5 seconds and outputs the last event that was
652652

653653
For more information, refer to [Hopping window](/stream-analytics-query/hopping-window-azure-stream-analytics).
654654

655-
## Processing events with independent time (Substreams)
655+
## Process events with independent time (Substreams)
656656

657-
Events can arrive late or out of order due to clock skews between event producers, clock skews between partitions, or even network latency.
657+
Events can arrive late or out of order due to clock skews between event producers, clock skews between partitions, or network latency.
658658
For example, the device clock for *TollID* 2 is five seconds behind *TollID* 1, and the device clock for *TollID* 3 is ten seconds behind *TollID* 1. A computation can happen independently for each toll, considering only its own clock data as a timestamp.
659659

660660
**Input**:
@@ -745,9 +745,9 @@ GROUP BY DeviceId,TumblingWindow(minute, 5)
745745

746746
For more information, refer to [COUNT(DISTINCT Time)](/stream-analytics-query/count-azure-stream-analytics).
747747

748-
## Session Window
748+
## Session Windows
749749

750-
A Session Window is a window that keeps expanding as events occurs, and closes for computation if no event is received after a specific amount of time or the window reaches its maximum duration.
750+
A Session Window is a window that keeps expanding as events occur and closes for computation if no event is received after a specific amount of time or if the window reaches its maximum duration.
751751
This window is particularly useful when computing user interaction data. A window starts when a user starts interacting with the system and closes when no more events are observed, meaning, the user has stopped interacting.
752752
For example, a user is interacting with a web page where the number of clicks is logged, a Session Window can be used to find out how long the user interacted with the site.
753753

0 commit comments

Comments
 (0)