I need to delete certain data from a delta-lake table before I load it. I am able to delete the data from delta table if it exists but it fails when the table does not exist.
Databricks scala code below
// create delete statement
val del_ID = "Check_ID =" + "123"
// get delta table from path where data exists
val deltaTable = DeltaTable.forPath(spark, path)
// delete data from delta table
deltaTable.delete(del_ID)
The above code works only if the delta data exists on that path otherwise it fails.
Can someone share an approach where the delete statement is executed if the delta data exists else the delete statement is ignored ?