Google Cloud Professional Data Engineer — Question 286

You are analyzing the price of a company's stock. Every 5 seconds, you need to compute a moving average of the past 30 seconds' worth of data. You are reading data from Pub/Sub and using DataFlow to conduct the analysis. How should you set up your windowed pipeline?

Answer options

Correct answer: D

Explanation

The correct answer is D because it allows for continuous calculation of the moving average every 5 seconds based on the most recent 30 seconds of data. Option A uses a fixed window which doesn't align with the requirement for a moving average. Option B also uses a fixed window and emits results too late for the moving average needed. Option C uses a sliding window but does not fit the 30-second data requirement effectively.