Performing time travel
A unique feature of Delta Lake is its ability to perform time travel. By using this feature, you can query and restore previous snapshots of your table. Access to previous snapshots is granted by using the versionAsOf
option.
Important Note
The time travel functionality in Delta Lake implements data lineage. Data lineage is an extremely critical tool for data audits and compliance purposes. The same feature comes in handy for data engineers who are trying to trace data anomalies.
- This is how you can query previous versions of the delta table. In this example, we are querying
version
0
of the table – in other words, when it was created:%sql SELECT * FROM store_orders VERSION AS OF 0 WHERE order_number=5;
This results in the following output:
Notice how the previous version of the table shows the
sale_ price
value as98.41
. - This time we will delete...