cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
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
Esteemed Contributor III
Esteemed Contributor III

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
Honored Contributor III
Honored Contributor III
## 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

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.