You're working with time series data in Snowflake, specifically website traffic data with timestamps and page views. You need to calculate the cumulative page views for each day. However, the data contains missing timestamps, and you want to fill those gaps with a default page view count of 0 before calculating the cumulative sum. Which of the following approaches, used in conjunction with a cumulative SUM aggregate function, is MOST efficient?
Correct Answer: B
Creating a separate date table and using a LEFT JOIN with COALESCE is the most efficient approach. Stored procedures (A) are generally slower for large datasets. Recursive CTEs (C) can be resource-intensive. Using UDFs or Lateral Flatten (D & E) may also increase complexity and overhead compared to a simple JOIN. The key is to leverage Snowflake's ability to handle joins efficiently.