Databricks ML Associate Practice Question 23: Feature Table Merge Write
Databricks Certified Machine Learning Associate · Test 3 · question 3 of 10
A feature table holds one row per customer for 40 million customers. A nightly job recomputes features only for the roughly 800,000 customers who were active that day and writes the result with fe.write_table(name=..., df=daily_df, mode="overwrite"). The next morning, batch scoring fails to find features for every inactive customer.
What should the job do instead?
Show answer and explanation
Answer:
mode="overwrite" replaces the table's contents with the DataFrame it is given, so a partial daily batch wipes the 39.2 million customers it does not mention, which is why lookups for inactive customers return nothing. mode="merge" is the incremental write path: rows whose primary key appears in the DataFrame are inserted or updated, and rows whose primary key does not appear remain unchanged. That is precisely the upsert semantics a daily delta needs, and it keeps the write proportional to the number of customers actually recomputed.
Option A produces a correct table by accident at a large and unnecessary cost. Reading all 40 million rows to rewrite all 40 million rows every night is a full-table write dressed up as an incremental one, and the union needs careful deduplication to avoid two rows per active customer.
Option B is the same full recomputation with worse properties. Dropping the table destroys its history, its primary key constraint and any grants on it, and downstream lookups fail while it does not exist.
Option C invents a parameter with borrowed semantics. checkpoint_location belongs to Structured Streaming writes and tracks stream progress; it does not make an overwrite behave selectively.
Reference: Update a feature table in Unity Catalog