
Databricks Certified Data Engineer - Associate
Get started today
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?
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?
Explanation:
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.