You operate an IoT solution for a plant manufacturing ceramic filter inserts for the automotive industry.
The critical part of the technology where the products are being baked in high-temperature ovens.
A large number of temperature data is collected from several ovens by sensors.
It is important when the average temperature exceeds a certain threshold, an alarm has to be triggered and a reset command to the alert output if the average machine temperature in a 30-second window reaches 200 degrees.
You have two solution candidates: # OPTION2
SELECT 'reset' AS command INTO alert FROM temperature TIMESTAMP BY timeCreated GROUP BY TumblingWindow(second,30) HAVING Avg(machine.temperature) > 200# OPTION1
SELECT 'reset' AS command INTO alert FROM temperature TIMESTAMP BY timeCreated GROUP BY HoppingWindow(second,30,30) HAVING Avg(machine.temperature) > 200Which one of the above code should you use?
Click on the arrows to vote for the correct answer
A. B. C. D.Correct Answer: C.
Option A is incorrect because the two codes produce exactly the same result.
OPTION2 is also correct.
Option B is incorrect because the two codes produce exactly the same result.
OPTION1 is also correct.
Option C is CORRECT because tumbling windows are a series of fixed-sized, non-overlapping and contiguous time intervals.
It is the best option for cases when data coming at regular intervals must be aggregated at fixed length periods.
On the other hand, a tumbling window is a special hopping window, with its ‘hop' size being equal to its ‘size'.
Option D is incorrect because both code segments are correct and implement windowing functions which deliver the required result.
References:
In this scenario, the task is to trigger an alarm and reset command to the alert output when the average temperature of the ovens exceeds 200 degrees in a 30-second window. The data is collected from multiple sensors that monitor temperature.
The two options provided for the query are:
OPTION1:
sqlSELECT 'reset' AS command INTO alert FROM temperature TIMESTAMP BY timeCreated GROUP BY HoppingWindow(second,30,30) HAVING Avg(machine.temperature) > 200
OPTION2:
sqlSELECT 'reset' AS command INTO alert FROM temperature TIMESTAMP BY timeCreated GROUP BY TumblingWindow(second,30) HAVING Avg(machine.temperature) > 200
Both options are using the Stream Analytics query language, which is a query language that is used to process data streams in real-time. The query language supports windowing functions that allow you to perform aggregate functions over a specific time interval.
In OPTION1, the HoppingWindow function is used to group the data into 30-second windows that hop every 30 seconds. This means that the data will be aggregated into 30-second windows, and the window will hop every 30 seconds. The query will trigger an alarm and reset command if the average temperature of the ovens exceeds 200 degrees in any of the windows.
In OPTION2, the TumblingWindow function is used to group the data into 30-second windows that do not overlap. This means that the data will be aggregated into non-overlapping 30-second windows. The query will trigger an alarm and reset command if the average temperature of the ovens exceeds 200 degrees in any of the windows.
Based on the scenario, the critical part of the technology is where the products are being baked in high-temperature ovens. The average temperature needs to be monitored continuously, and an alarm needs to be triggered if the temperature exceeds a certain threshold. Therefore, the query needs to be designed in a way that can capture the temperature data accurately and trigger an alarm if the temperature exceeds the threshold.
Since the temperature data is critical, it is essential to have an accurate and timely response. The TumblingWindow function in OPTION2 provides a better approach to capturing the temperature data since it does not overlap and is more precise. OPTION1 using the HoppingWindow function may miss critical temperature spikes in the oven, as the window can only process the data at intervals.
Therefore, the correct answer is B. Only OPTION2.