dmart
New Contributor III

Azure support can't solve the problem.

It appears there is no solution and the answer to my question is "it can't be deleted". The only option is to delete the entire workspace.

This definitely is NOT a solution to my problem or even what I was asking for in this post but this is the closest I could get. This actually starts deleting data but at a pace that will take months or years to finish given data I need deleted.

 

 

 

CELL_1

%scala

//collect the paths of the inner partitions recursively, list the paths, and delete them in parallel (limit partition size to memory exhaustion)

import scala.util.{Try, Success, Failure}

def delete(p: String): Unit = {
  dbutils.fs.ls(p).map(_.path).toDF.foreach { file =>
    dbutils.fs.rm(file(0).toString, true)
    println(s"deleted file: $file")
  }
}

final def walkDelete(root: String)(level: Int): Unit = {
  dbutils.fs.ls(root).map(_.path).foreach { p =>
    println(s"Deleting: $p, on level: ${level}")
    val deleting = Try {
      if(level == 0) delete(p)
      else if(p endsWith "/") walkDelete(p)(level-1)
      else delete(p)
    }
    deleting match {
      case Success(v) => {
        println(s"Successfully deleted $p")
        dbutils.fs.rm(p, true)
      }
      case Failure(e) => println(e.getMessage)
    }
  }
}


CELL_2

%scala

val root = "/path/to/data"
walkDelete(root)(0)