
Explanation:
B. preds.write.mode("append").saveAsTable("churn_preds")
append mode ensures that each day's predictions are added as new rows to the existing Delta table. This preserves historical data, enabling comparisons across time.saveAsTable defaults to the Delta format. This provides ACID transactions and time-travel capabilities out of the box.errorIfExists. This snippet would fail on the second day because the path already exists.overwrite replaces the entire dataset every day, making it impossible to perform the historical comparisons requested by the team.Trigger.AvailableNow, the simplicity and lower overhead of a batch append make it the preferred choice for this specific frequency. Additionally, Option A uses overwrite, which destroys the history the team requires.Ultimate access to all questions.
No comments yet.
A data science team needs to store daily churn predictions generated by a production MLflow model in a Delta Lake table. The solution must support historical analysis, allowing data scientists to compare predictions over time. Churn predictions are generated at most once per day. Which code snippet achieves this requirement with the lowest compute overhead and cost?
A
(preds.writeStream
.outputMode("overwrite")
.option("checkpointPath", "/_checkpoints/churn_preds")
.start("/preds/churn_preds"))
(preds.writeStream
.outputMode("overwrite")
.option("checkpointPath", "/_checkpoints/churn_preds")
.start("/preds/churn_preds"))
B
preds.write.mode("append").saveAsTable("churn_preds")
preds.write.mode("append").saveAsTable("churn_preds")
C
preds.write.format("delta").save("/preds/churn_preds")
preds.write.format("delta").save("/preds/churn_preds")
D
(preds.writeStream
.outputMode("append")
.option("checkpointPath", "/_checkpoints/churn_preds")
.table("churn_preds"))
(preds.writeStream
.outputMode("append")
.option("checkpointPath", "/_checkpoints/churn_preds")
.table("churn_preds"))
E
(preds.write
.format("delta")
.mode("overwrite")
.saveAsTable("churn_preds"))
(preds.write
.format("delta")
.mode("overwrite")
.saveAsTable("churn_preds"))