Skip to content

A scenario for a data engineer · Junior and up

Someone deleted the customers

Patch · Your teammate
Friday, 16:55

A colleague ran a DELETE with the wrong filter on the customers Delta table. Half the rows are gone, and they are asking, quietly, whether it can be undone.

What do you do?

Tap the one you would do. The answer opens below.

Show the best call

Look at the table history, then restore the table to the version before the delete.

Back in under a minute. You both go home on time.

Why

A Delta table keeps earlier versions for a while. DESCRIBE HISTORY lists them and RESTORE returns to one. VACUUM is what removes the old files, which is why its retention period matters.

Read it in the Databricks docs (opens in a new tab)

The other two

Works, at a price. Reload the whole table from the source system.
It works, four hours later, and only for the rows the source system still has.
A poor call. Run VACUUM with no retention first, to clear out the broken files.
Databricks refuses this until you switch off a safety check. Switch it off, and the old files a restore needs are gone.

The words in this scenario

RESTORE and table history.
A Delta table keeps a history of its versions. A query can read an earlier version, and RESTORE puts the table back to one. In the docs (opens in a new tab)
VACUUM.
A command that deletes the data files a Delta table no longer uses, once they are older than the retention period. In the docs (opens in a new tab)

Go deeper on brickster.ai

More scenarios

Had one like this at work? Send it to us: the best tickets come from real incidents.

Checked against the Databricks documentation on . brickster.ai is independent and is not affiliated with Databricks.