gpt4 book ai didi

apache-spark - 文件已经存在pyspark

转载 作者:行者123 更新时间:2023-12-01 11:22:12 24 4
gpt4 key购买 nike

我找不到在 hadoop pyspark 中删除 hdfs 输出文件的方法。使用命令:

hadoop fs -rmdir "path/outputFile.csv"

当我运行具有相同输出文件名的新作业时,我收到错误 FileAlreadyExist。

有人知道如何处理这种情况吗?提前致谢

最佳答案

在命令行中,您可以使用命令:

hdfs dfs rm -r /path/to/myDir/

在 Spark 中,您可以(在 Scala 中):

import org.apache.hadoop.fs.{FileSystem,Path}
import java.net.URI

val dirPath = "/path/to/my/dir/"
val fileSystem = FileSystem.get(URI.create(dirPath), sqlContext.sparkContext.hadoopConfiguration)
fileSystem.delete(new Path(dirPath), true)

关于apache-spark - 文件已经存在pyspark,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40842644/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com