0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

sparkでhdfs上のdataを削除するには

Posted at
def deleteFile(filepath: String, uri: String = "hdfs://localhost:9000") {

    val hadoopConf = new org.apache.hadoop.conf.Configuration()
    val hdfs = org.apache.hadoop.fs.FileSystem.get(new java.net.URI(uri), hadoopConf)
    try { 
        hdfs.delete(new org.apache.hadoop.fs.Path(filepath), true) 
    } catch { 
      case e : Throwable => e.printStackTrace
    }
}

みたいな感じで、

  • dateframeを使えば、overwrite optionでsaveできる

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?