
Answer-first summary for fast verification
Answer: SELECT * FROM table_name TIMESTAMP AS OF date_sub(current_date(), 1)
The correct method to query historical data is `SELECT * FROM table_name TIMESTAMP AS OF date_sub(current_date(), 1)`. Delta Time Travel offers two approaches for accessing historical data: using a timestamp or a version number. The timestamp method allows you to specify a point in time, such as a date or a precise timestamp, to query the data as it existed at that moment. For example, `SELECT count(*) FROM my_table TIMESTAMP AS OF '2019-01-01'` or `SELECT count(*) FROM my_table TIMESTAMP AS OF date_sub(current_date(), 1)`. The version number method involves specifying a version number to access the data in a specific state, like `SELECT count(*) FROM my_table VERSION AS OF 5238`. For more details, refer to the [Delta Time Travel documentation](https://databricks.com/blog/2019/02/04/introducing-delta-time-travel-for-large-scale-data-lakes.html).
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
You've discovered that a process inadvertently updated a table, and you need to query yesterday's version of the data for analysis. What is the most effective method to access historical data for this purpose?
A
SELECT * FROM TIME_TRAVEL(table_name) WHERE time_stamp = ‘timestamp‘
B
TIME_TRAVEL FROM table_name WHERE time_stamp = date_sub(current_date(), 1)
C
SELECT * FROM table_name TIMESTAMP AS OF date_sub(current_date(), 1)
D
DISCRIBE HISTORY table_name AS OF date_sub(current_date(), 1)
E
SHOW HISTORY table_name AS OF date_sub(current_date(), 1)
No comments yet.