Google Professional Data Engineer Question 184
Select 2Google Cloud PlatformYou are designing a data pipeline for an e-commerce platform that processes customer transactions in real-time. To optimize reporting performance, you decide to precalculate certain fields before storing the data in BigQuery. Which of the following fields are good candidates for precalculation?
- A
Total transaction amount calculated as the sum of item prices in the transaction
- B
Customer's age calculated based on their date of birth
- C
Product inventory levels dynamically updated in real-time
- D
A flag indicating whether the total transaction amount exceeds a pre-defined threshold
- E
The timestamp of when the transaction was processed
Show answer and explanation
Correct answers: A, D
Explanation
Precalculating fields can improve query performance by reducing the need for on-the-fly computations during query execution. Fields like the total transaction amount and threshold flags are derived values that remain static after calculation and are well-suited for this purpose. However, fields that change over time (e.g., age) or require real-time updates (e.g., inventory levels) are not appropriate for precalculation.
- A. Correct.
Precalculating the total transaction amount reduces the need for repeated calculations during queries, making it a good candidate for precalculation.
- B. Incorrect.
Customer's age is not a good candidate for precalculation as it changes over time, and storing a static value would lead to inaccuracies.
- C. Incorrect.
Product inventory levels are typically updated dynamically in real-time and are not suitable for precalculation as they are subject to frequent changes.
- D. Correct.
A flag indicating whether the total transaction amount exceeds a threshold is a derived field that can be precalculated to simplify queries and improve performance.
- E. Incorrect.
Timestamps are usually recorded as raw data and do not benefit from precalculation since they are not derived or aggregated fields.