Databricks Data Engineer Associate Question 287
Single answerYou are working on a Databricks Delta table named 'sales_data' that has gone through several updates. Due to an error in a recent update, you need to roll back the table to a version from two days ago. Which of the following steps would allow you to achieve this?
- A
Use the RESTORE TABLE command to revert the table to a specific version or timestamp.
- B
Use the DESCRIBE HISTORY command to identify the table version, then use the RESTORE TABLE command with the version number.
- C
Overwrite the table with a backup copy of the data stored externally.
- D
Utilize the OPTIMIZE command with a rollback parameter to revert the table to a previous state.
Show answer and explanation
Correct answer: B
Explanation
Delta Lake supports rollback functionality by allowing users to access previous table versions using version numbers or timestamps. First, you would use the DESCRIBE HISTORY command to view the table’s change history and identify the desired version. Then, you can restore the table using the RESTORE TABLE command or by specifying the version in a SELECT query. This ensures you can safely revert changes without relying on external backups or other unrelated commands.
- A. Incorrect.
The RESTORE TABLE command is not a valid Delta Lake command. While Delta Lake supports rollback functionality, this is achieved using specific versioning or timestamps, not a RESTORE TABLE command.
- B. Correct.
This is correct. The DESCRIBE HISTORY command allows you to view the history of changes to the table, including version numbers. After identifying the required version, you can use the RESTORE TABLE command with the version number to roll back the table.
- C. Incorrect.
Overwriting the table with an external backup is not related to Delta Lake's versioning capabilities. While this approach might work, it does not leverage Delta Lake's built-in rollback features.
- D. Incorrect.
The OPTIMIZE command is used to compact files for better performance in Delta Lake and does not include any rollback functionality.