
Answer-first summary for fast verification
Answer: All logic will execute at query time and return the result of joining the valid versions of the source tables at the time the query began.
A view in Databricks does not materialize or store data when defined; it dynamically executes the underlying query each time it is queried. Since the source tables (users and orders) are Delta Lake tables, Delta Lake's ACID transaction guarantees ensure that the query operates on a consistent snapshot of the data as of the start of the query (snapshot isolation). Even if the source tables are modified during query execution, the view's results will reflect the state of the tables at the time the query began. Options A and B incorrectly suggest precomputed or cached results, which do not apply to standard views. Option C is incorrect because it references the state at query completion, whereas Delta Lake uses the snapshot at query start (Option D).
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
A view named recent_orders is created with the following SQL code:
CREATE VIEW recent_orders AS (
SELECT a.user_id, a.email, b.order_id, b.order_date
FROM
(SELECT user_id, email
FROM users) a
INNER JOIN
(SELECT user_id, order_id, order_date
FROM orders
WHERE order_date >= (current_date() - 7)) b
ON a.user_id = b.user_id
)
CREATE VIEW recent_orders AS (
SELECT a.user_id, a.email, b.order_id, b.order_date
FROM
(SELECT user_id, email
FROM users) a
INNER JOIN
(SELECT user_id, order_id, order_date
FROM orders
WHERE order_date >= (current_date() - 7)) b
ON a.user_id = b.user_id
)
Both users and orders are Delta Lake tables.
What describes the results when querying recent_orders?
A
All logic will execute when the view is defined and store the result of joining tables to the DBFS; this stored data will be returned when the view is queried.
B
Results will be computed and cached when the view is defined; these cached results will incrementally update as new records are inserted into source tables.
C
All logic will execute at query time and return the result of joining the valid versions of the source tables at the time the query finishes.
D
All logic will execute at query time and return the result of joining the valid versions of the source tables at the time the query began.
No comments yet.