RESTORE (Delta Lake on Databricks)

Note

Available in Databricks Runtime 7.4 and above.

Restores a Delta table to an earlier state. Restoring to an earlier version number or a timestamp is supported.

Syntax

RESTORE [TABLE] table_identifier[TO] <time_travel_version>

where

  • table_identifier
    • [database_name.] table_name: A table name, optionally qualified with a database name.
    • delta.`<path-to-table>` : The location of an existing Delta table.
<time_travel_version>  =
  TIMESTAMP AS OF <timestamp_expression> |
  VERSION AS OF <version>

where

  • timestamp_expression can be any one of:
    • '2018-10-18T22:15:12.013Z', that is, a string that can be cast to a timestamp
    • cast('2018-10-18 13:36:32 CEST' as timestamp)
    • '2018-10-18', that is, a date string
    • In Databricks Runtime 6.6 and above:
      • current_timestamp() - interval 12 hours
      • date_sub(current_date(), 1)
      • Any other expression that is or can be cast to a timestamp
  • version is a long value that can be obtained from the output of DESCRIBE HISTORY table_spec.

Neither timestamp_expression nor version can be subqueries.

For more information about the RESTORE command, see Restore a Delta table.