Databricks Data Engineer Associate Question 291
Single answerYou are working with a Delta table named sales_data in Databricks. A recent update to the table introduced an issue, and you need to query the version of the table before the update to verify the data. Which of the following commands will allow you to query the Delta table at a specific version?
- A
SELECT * FROM sales_data VERSION AS OF 5;
- B
SELECT * FROM sales_data TIMESTAMP AS OF '2023-09-15T10:00:00';
- C
SELECT * FROM delta.
/mnt/data/sales_dataVERSION AS OF 5; - D
SELECT * FROM delta.
/mnt/data/sales_dataTIMESTAMP AS OF '2023-09-15T10:00:00';
Show answer and explanation
Correct answer: C
Explanation
To query a specific version of a Delta table, you must use the VERSION AS OF syntax along with the Delta table path (e.g., delta./mnt/data/sales_data). The table name alone cannot be used directly with this syntax in a SQL query. Option 3 correctly demonstrates how to query the Delta table at a specific version.
- A. Incorrect.
This is incorrect because the syntax 'VERSION AS OF' cannot be used directly with a table name in a standard SQL query.
- B. Incorrect.
This is incorrect because the syntax 'TIMESTAMP AS OF' cannot be used directly with a table name in a standard SQL query.
- C. Correct.
This is correct because querying a Delta table at a specific version requires using the Delta path and the appropriate 'VERSION AS OF' syntax.
- D. Incorrect.
This is incorrect because while the 'TIMESTAMP AS OF' syntax is valid, the question specifically asks for querying by version, not by timestamp.