简体   繁体   中英

Spark Delta table restore to version

I am trying to restore a delta table to its previous version via spark java, am using local ide.code is as below

import io.delta.tables.*; 
DeltaTable deltaTable = DeltaTable.forPath(spark, <path-to-table>); 
DeltaTable deltaTable = DeltaTable.forName(spark, <table-name>); 
deltaTable.restoreToVersion(0) // restore table to     oldest version
deltaTable.restoreToTimestamp("2019-02-14") // restore to a specific timestamp

As per the documentation databricks doc the method given here is not available in delta-core version 0.8.0. The method is also not in the api docs .

Is this only available in Datbricks run time?

Currently i have to load with the previous version and rewrite the df using delta.Is there any better way to do it?

As you correctly guessed, those methods restoreToVersion and restoreToTimestamp are specific to databricks and not present in open-source deltalake version. There is no trace of such methods in open-source deltalake as you can check in delta-lake repository

So currently and as far as I know, there is no other method than rewriting from a previous version, as explained in answers of this question

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM