Databricks Data Engineer Associate Question 280
Single answerYou are working on a Delta table in Databricks and notice a recent update has introduced incorrect data. You decide to roll back the table to a previous version. Which of the following commands can be used to achieve this?
- A
RESTORE TABLE table_name TO VERSION AS OF 5
- B
ROLLBACK TABLE table_name TO VERSION 5
- C
ALTER TABLE table_name ROLLBACK TO VERSION 5
- D
RESTORE table_name TO VERSION AS OF 5
Show answer and explanation
Correct answer: A
Explanation
In Delta Lake, rolling back a table to a previous version is achieved using the RESTORE TABLE command followed by the table name and the TO VERSION AS OF clause. This allows users to restore the table's state to a specific version in its transaction history. Incorrect options either use invalid syntax or commands not supported in Delta Lake.
- A. Correct.
This is the correct syntax supported by Delta Lake for rolling back a table to a previous version. The
RESTORE TABLEcommand is used, followed by the table name and theTO VERSION AS OFclause. - B. Incorrect.
This is not a valid Delta Lake command. The
ROLLBACK TABLEsyntax does not exist in Databricks or Delta Lake. - C. Incorrect.
This is not a valid Delta Lake command. Delta Lake does not support an
ALTER TABLErollback syntax. - D. Incorrect.
Although similar, this option is invalid because the
RESTOREkeyword alone does not match Delta Lake's syntax. The correct command includes theTABLEkeyword afterRESTORE.