Databricks Data Engineer Associate Question 284
Single answerYou are managing a Delta table in Databricks for a data pipeline. A recent update to the table introduced incorrect data, and you need to revert the table to its previous state before the update. Which statement would allow you to roll back the table to a previous version?
- A
RESTORE TABLE delta.
/path/to/tableTO VERSION AS OF 5 - B
ALTER TABLE delta.
/path/to/tableSET VERSION = 5 - C
ROLLBACK TABLE delta.
/path/to/tableTO VERSION AS OF 5 - D
REVERT TABLE delta.
/path/to/tableTO VERSION 5
Show answer and explanation
Correct answer: A
Explanation
Delta Lake provides versioning for tables, allowing you to roll back a table to a previous state using the RESTORE TABLE command. This is particularly useful when you need to recover from accidental changes or data corruption. The correct syntax for rolling back a Delta table is RESTORE TABLE <table-name> TO VERSION AS OF <version-number>.
- A. Correct.
This is the correct syntax to restore a Delta table to a previous version. The
RESTORE TABLEcommand is used for rolling back a table to a specific version. - B. Incorrect.
The
ALTER TABLEcommand is used for modifying table properties, but it cannot be used to roll back a Delta table to a previous version. - C. Incorrect.
The
ROLLBACK TABLEcommand is not a valid Databricks or Delta Lake command. It does not exist in the Delta Lake syntax. - D. Incorrect.
The
REVERT TABLEcommand is not a valid Databricks or Delta Lake command. It does not exist in the Delta Lake syntax.