Databricks Data Engineer Professional Question 72
Select 2You are working with a Delta table in Databricks containing customer data. A new data source provides updated information about some existing customers, and you need to ensure the Delta table reflects these changes. Which of the following strategies can be used to update multiple records in the Delta table (Type 1 updates)?
- A
Use the Delta Lake
MERGEstatement to match and update records - B
Perform an overwrite of the entire Delta table with the updated dataset
- C
Use the
UPDATEstatement in Delta Lake to modify the relevant records - D
Use the
INSERT OVERWRITEstatement to only update the relevant partitions - E
Export the Delta table to an external database, update the records there, and re-import it
Show answer and explanation
Correct answers: A, C
Explanation
For Type 1 updates in Delta Lake, you can use the MERGE statement to perform upserts or the UPDATE statement to modify specific records directly. These operations are optimized for Delta tables and avoid the inefficiencies and complexities of alternatives like overwriting the entire table or using external systems.
- A. Correct.
Correct: The
MERGEstatement in Delta Lake allows you to handle updates to specific records by matching keys and performing upserts (Type 1 updates). - B. Incorrect.
Incorrect: Overwriting the entire dataset is not efficient for updating only a few records and is not a recommended approach when Delta Lake provides better alternatives like
MERGEorUPDATE. - C. Correct.
Correct: The
UPDATEstatement in Delta Lake can directly modify specific records based on a condition, making it suitable for Type 1 updates. - D. Incorrect.
Incorrect: The
INSERT OVERWRITEstatement is suitable for replacing entire partitions, but it is not ideal for updating individual records in a Delta table. - E. Incorrect.
Incorrect: Exporting the Delta table to an external database, updating it there, and re-importing it is unnecessarily complex and inefficient compared to native Delta Lake operations.