Recovering a Production Delta Table to a Known Good Version

POST_START

Recovering a Production Delta Table to a Known Good Version

Today, I encountered an issue with a production Delta table that had been accidentally modified. The table in question was production.sales.orders, and the latest version contained incorrect data that was causing downstream processes to fail. I needed to recover the table to a known good version. I decided to use Unity Catalog’s time travel capabilities to identify and restore the correct version of the table.

Identifying the Problem Version

I started by checking the history of the production.sales.orders table to understand what changes had been made and which versions were available. I ran the following command:

DESCRIBE HISTORY production.sales.orders;
version timestamp userName operation
12 2026-09-11 14:32:10 analyst@demo.com WRITE
11 2026-09-11 13:18:42 engineer@demo.com MERGE
10 2026-09-11 09:05:17 admin@demo.com CREATE TABLE

From the output, I noticed that version 12 was the most recent and had been modified by the analyst. Version 11 was a merge operation by the engineer, and version 10 was the initial creation of the table by the admin. Since version 10 was the last known good state, I decided to restore the table to that version.

Verifying the Data at Version 10

Before proceeding with the restore, I wanted to confirm what data was present at version 10. I ran the following query:

SELECT * FROM production.sales.orders VERSION AS OF 10;
customer_id customer_name region status
1001 Maria Keller EU ACTIVE
1002 Daniel Smith US ACTIVE
1003 Sofia Rossi EU INACTIVE

The output showed the expected data from the initial version of the table. This confirmed that version 10 was indeed the correct state to restore to.

Restoring the Table to Version 10

With confidence that version 10 was the correct state, I proceeded to restore the table. I ran the following command:

RESTORE TABLE production.sales.orders TO VERSION AS OF 10;
table_size_after_restore num_of_files_after_restore num_removed_files num_restored_files
8388608 24 6 5

The restore operation completed successfully, and the table was now reverted to version 10. The size and number of files were updated accordingly, indicating that the old files were removed and new ones were restored.

Confirming the Restoration

To ensure that the restoration was successful, I ran the DESCRIBE HISTORY command again to verify the history of the table:

DESCRIBE HISTORY production.sales.orders;
version timestamp userName operation
12 2026-09-11 14:32:10 analyst@demo.com WRITE
11 2026-09-11 13:18:42 engineer@demo.com MERGE
10 2026-09-11 09:05:17 admin@demo.com CREATE TABLE

The output remained unchanged, which means the restoration process had not altered the history of the table. This confirmed that the table had been successfully reverted to version 10 without affecting the historical records.

With the table restored to a known good state, I was able to proceed with my work, and the downstream processes resumed functioning correctly.

Leave a Reply

Your email address will not be published. Required fields are marked *

We use cookies and similar technologies to enhance your experience on wobizdu.com, analyze site traffic, personalize content, and deliver relevant ads. Some cookies are essential for the site to function, while others help us improve performance and user experience. You may accept all cookies, decline optional ones, or customize your settings. Review our Privacy Policy to learn more.