Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delta lake RESTORE issue (Databricks)

I am working on Azure databricks and created a delta table on ADLS Gen2.

I have 4 versions of delta lake created already.

I am trying to restore to version number 2 with the following command.

%sql
RESTORE TABLE Sales TO VERSION AS OF 2

Could someone let me know why I am not able to restore to the older version? The error as below happening now.

Error in SQL statement: ParseException: 
extraneous input 'RESTORE' expecting {'(', 'CONVERT', 'COPY', 'OPTIMIZE', 'ADD', 'ALTER', 'ANALYZE', 'CACHE', 'CLEAR', 'COMMENT', 'COMMIT', 'CREATE', 'DELETE', 'DESC', 'DESCRIBE', 'DFS', 'DROP', 'EXPLAIN', 'EXPORT', 'FROM', 'GRANT', 'IMPORT', 'INSERT', 'LIST', 'LOAD', 'LOCK', 'MAP', 'MERGE', 'MSCK', 'REDUCE', 'REFRESH', 'REPLACE', 'RESET', 'REVOKE', 'ROLLBACK', 'SELECT', 'SET', 'SHOW', 'START', 'TABLE', 'TRUNCATE', 'UNCACHE', 'UNLOCK', 'UPDATE', 'USE', 'VALUES', 'WITH'}(line 1, pos 0)

== SQL ==
RESTORE TABLE Sales TO VERSION AS OF 2
like image 571
Lilly Avatar asked Oct 31 '25 22:10

Lilly


1 Answers

Please check that you're using the correct version of the Databricks Runtime. Per documentation it's available since DBR 7.4 only, and not in the earlier versions. I just checked on DBR 7.5, and it works just fine

If you're on the earlier versions of Databricks Runtime, then you can use INSERT OVERWRITE statement with select of specific version of the table:

insert overwrite <table> SELECT * FROM <table> VERSION AS OF <version>

Or another possibility is to use TRUNCATE TABLE + INSERT INTO:

truncate table <table>;
INSERT INTO <table> SELECT * FROM <table> VERSION AS OF <version>
like image 145
Alex Ott Avatar answered Nov 04 '25 05:11

Alex Ott



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!