Databricks Data Engineer Associate Question 278
Single answerA data engineer is working with a Delta table in Databricks and discovers that a recent update has introduced errors in the data. They want to roll back the Delta table to a previous version using the Delta Lake Time Travel feature. Which of the following commands can they use to achieve this?
- A
RESTORE TABLE table_name TO VERSION AS OF 5
- B
SELECT * FROM table_name VERSION AS OF 5
- C
DROP TABLE table_name; CREATE TABLE table_name AS SELECT * FROM table_name VERSION AS OF 5
- D
ALTER TABLE table_name REVERT TO VERSION 5
Show answer and explanation
Correct answer: A
Explanation
The correct way to roll back a Delta table to a previous version is by using the RESTORE TABLE command with the appropriate version. This ensures the table is restored to its earlier state without requiring manual recreation of the table or querying historical data temporarily.
- A. Correct.
This is the correct syntax for rolling back a Delta table to a specific version using Delta Lake's RESTORE command. It effectively restores the table to the state it was in at the specified version.
- B. Incorrect.
This syntax is used for querying historical data using Delta Time Travel but does not roll back the table to a previous version permanently.
- C. Incorrect.
This approach involves manually recreating the table by querying a previous version. While it could theoretically replicate the rollback effect, it is not the intended or efficient method for rolling back a Delta table.
- D. Incorrect.
This syntax is invalid in Delta Lake as there is no 'REVERT' command to roll back to a previous version.