cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

What is the Pyspark equivalent of FSCK REPAIR TABLE?

Dean_Lovelace
New Contributor III

I am using the delta format and occasionaly get the following error:-

"xx.parquet referenced in the transaction log cannot be found. This occurs when data has been manually deleted from the file system rather than using the table `DELETE` statement"

FSCK REPAIR TABLE works for Hive based tables, but I am using the file system only.

How can I re-create the delta transaction log (rather than rebuilding the whole dataset)?

3 REPLIES 3

Debayan
Databricks Employee
Databricks Employee

Hi, Please refer to https://kb.databricks.com/delta/filereadexception-when-reading-delta-table.

Please let us know if this helps.

Also, please tag @Debayan Mukherjeeโ€‹ with your next response which will notify me. Thank you!

Anonymous
Not applicable

Hi @Dean Lovelaceโ€‹ 

Thank you for posting your question in our community! We are happy to assist you.

To help us provide you with the most accurate information, could you please take a moment to review the responses and select the one that best answers your question?

This will also help other community members who may have similar questions in the future. Thank you for your participation and let us know if you need any further assistance! 

shan_chandra
Databricks Employee
Databricks Employee
## Delta check when a file was added
%scala
(oldest-version-available to newest-version-available).map { version =>
  var df = spark.read.json(f"<delta-table-location>/_delta_log/$version%020d.json").where("add is not null").select("add.path")
  var df2 = df.filter('path.contains("name-of-the-parquet-file"))
  if (df2.count > 0) {
    print("********* " + version)
  }
}

@Dean Lovelaceโ€‹ - Please use the above code snippet to identify in which available version the file is present.

change oldest-version-available to newest-version-available for the numbers of the delta History that you would like to check change the delta path to your delta table.

If you are facing this issue while reading (after doing FSCK REPAIR), could you please try using the below config.

spark.sql.files.ignoreCorruptFiles true
spark.sql.files.ignoreMissingFiles true

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group