
Answer-first summary for fast verification
Answer: RESTORE TABLE orders TO TIMESTAMP AS OF current_timestamp() - INTERVAL ‘8‘ HOURS;
The correct syntax for restoring a Delta table to a previous state is `RESTORE TABLE table_name TO TIMESTAMP AS OF timestamp_expression`. The `timestamp_expression` can be a variety of formats, including `current_timestamp() - INTERVAL ‘8‘ HOURS`, which accurately represents the time 8 hours before the current timestamp. This command allows the data engineer to revert the `orders` table to its state before the failed job execution. For more details, refer to the RESTORE documentation in Databricks SQL.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
A job scheduled to run daily at 12:00 AM loads data into the orders table, typically taking 30 minutes to complete. However, on a particular day, it failed after 5 minutes, leaving the table in an inconsistent state. A data engineer noticed the discrepancy between source and target counts the next morning at 8:00 AM and decided to restore the table to its state before the job ran and then re-run the job. Which SQL statement should the engineer use to restore the table?
A
ROLLBACK TABLE orders TO TIMESTAMP AS OF current_timestamp() - INTERVAL 8 HOURS;
B
RESTORE TABLE orders TO TIMESTAMP current_timestamp() - INTERVAL 8 HOURS;
C
RESTORE orders TO TIMESTAMP AS OF current_timestamp() - 8 HOURS;
D
ROLLBACK orders TO TIMESTAMP current_timestamp() - 8 HOURS;
E
RESTORE TABLE orders TO TIMESTAMP AS OF current_timestamp() - INTERVAL ‘8‘ HOURS;
No comments yet.