Databricks Data Engineer Associate Question 290
Single answerYou are working with a Delta table in Databricks which tracks sales transactions. A recent update to the table introduced an error, and you need to query the table as it existed before the update. How can you query the specific version of the Delta table prior to the update?
- A
Use the 'VERSION AS OF' clause in the SQL query to specify the table version.
- B
Use the 'TIME TRAVEL' clause in the SQL query to reference the previous state of the table.
- C
Query the Delta table's history and use the 'VERSION AS OF' clause to select the required version.
- D
Use the 'RESTORE TABLE' command to revert the table to the desired version.
Show answer and explanation
Correct answer: A
Explanation
To query a specific version of a Delta table, you can use the 'VERSION AS OF' clause in a SQL query. This enables you to directly access the state of the table as it existed at a specific version number without permanently altering the table. This is a key feature of Delta Lake's time travel functionality.
- A. Correct.
Correct. The 'VERSION AS OF' clause allows you to query a specific version of a Delta table by its version number.
- B. Incorrect.
Incorrect. There is no 'TIME TRAVEL' clause in Delta Lake. Time travel functionality is implemented through 'VERSION AS OF' or 'TIMESTAMP AS OF'.
- C. Incorrect.
Incorrect. While querying the Delta table's history can help identify the version number, you still need to use the 'VERSION AS OF' clause to query a specific version.
- D. Incorrect.
Incorrect. The 'RESTORE TABLE' command reverts the table to a specific version for all users, but it does not allow querying a specific version without restoring the table.