DEA-C02 · Question #96
A Data Engineer is querying a large table (+100 million rows) with the following SQL: select name , address , datediff(year, birthdate, current_date()) from customers; The Engineer notices that the re
The correct answer is D. Non-deterministic calculations are not stored in the results cache.. Option D is correct because current_date() is a non-deterministic function - its return value depends on when the query runs, not just the underlying data. Snowflake's results cache cannot safely reuse a prior result when a function could produce a different value on re-execution
Question
A Data Engineer is querying a large table (+100 million rows) with the following SQL:
select name , address , datediff(year, birthdate, current_date()) from customers; The Engineer notices that the results cache is not being used on subsequent executions of the query. The underlying table does not change and the data is not updated in between query executions. What is causing this to occur?
Options
- ACalculations are not stored in the results cache.
- BLarge results are not stored in the results cache.
- CDate functions are not stored in the results cache.
- DNon-deterministic calculations are not stored in the results cache.
How the community answered
(25 responses)- B4% (1)
- C4% (1)
- D92% (23)
Explanation
Option D is correct because current_date() is a non-deterministic function - its return value depends on when the query runs, not just the underlying data. Snowflake's results cache cannot safely reuse a prior result when a function could produce a different value on re-execution (e.g., at midnight the date changes), so the cache is bypassed entirely regardless of whether the table data changed.
Option A is wrong because deterministic calculations (like DATEDIFF with fixed input dates) are cached - the problem is specifically the non-deterministic nature of current_date(), not calculations in general. Option B is wrong because table/result size does not itself disqualify a query from result caching. Option C is wrong because not all date functions bypass the cache - only non-deterministic ones like current_date(), current_timestamp(), and random() do.
Memory tip: Ask yourself, "Could this function return a different value if I run the query one second later?" If yes (like current_date() or current_timestamp()), it's non-deterministic and will always skip the results cache.
Topics
Community Discussion
No community discussion yet for this question.