
Answer-first summary for fast verification
Answer: All logic will execute when the table is defined and store the result of joining tables to the DBFS; this stored data will be returned when the table is queried.
The CREATE TABLE AS SELECT (CTAS) statement in Delta Lake materializes the result of the query into a new table at the time of creation. This means the data from the source tables (users and orders) is read once, joined, filtered, and stored into the recent_orders table in DBFS. Subsequent queries against recent_orders will return the stored data as it existed when the table was created, not reflecting any changes to the source tables afterward. Option B correctly describes this behavior, where logic executes once during table creation and stored data is returned. Other options either assume dynamic computation (A, D), incremental updates (C), or incorrect transaction log usage (E), which do not apply to static CTAS tables.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.
A table named recent_orders is created with the following code:
CREATE TABLE 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 TABLE 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 at query time and return the result of joining the valid versions of the source tables at the time the query finishes.
B
All logic will execute when the table is defined and store the result of joining tables to the DBFS; this stored data will be returned when the table is queried.
C
Results will be computed and cached when the table is defined; these cached results will incrementally update as new records are inserted into source tables.
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.
E
The versions of each source table will be stored in the table transaction log; query results will be saved to DBFS with each query.