【发布时间】:2018-07-27 15:24:48
【问题描述】:
我正在尝试在本地创建镶木地板文件几天。我第一次运行代码时,一切正常。第二次删除文件失败。第三次删除另一个文件失败。哪个文件不能删除是完全随机的。
我需要它来工作的原因是因为我想在过去 7 天里每天创建镶木地板文件。因此,应该用更新的数据覆盖已经存在的 parquet 文件。
我使用 Project SDK 1.8、Scala 版本 2.11.8 和 Spark 版本 2.0.2。
第二次运行该行代码后:
newDF.repartition(1).write.mode(SaveMode.Overwrite).parquet(
OutputFilePath + "/day=" + DateOfData)
出现此错误:
WARN FileUtil:
Failed to delete file or dir [C:\Users\...\day=2018-07-15\._SUCCESS.crc]:
it still exists.
Exception in thread "main" java.io.IOException:
Unable to clear output directory file:/C:/Users/.../day=2018-07-15
prior to writing to it
at org.apache.spark.sql.execution.datasources.InsertIntoHadoopFsRelationCommand.run(InsertIntoHadoopFsRelationCommand.scala:91)
第三次之后:
WARN FileUtil: Failed to delete file or dir
[C:\Users\day=2018-07-20\part-r-00000-8d1a2bde-c39a-47b2-81bb-decdef8ea2f9.snappy.parquet]: it still exists.
Exception in thread "main" java.io.IOException: Unable to clear output directory file:/C:/Users/day=2018-07-20 prior to writing to it
at org.apache.spark.sql.execution.datasources.InsertIntoHadoopFsRelationCommand.run(InsertIntoHadoopFsRelationCommand.scala:91)
如您所见,这是第二次运行代码之后的另一个文件。 依此类推。手动删除文件后,可以创建所有拼花文件。
有人知道这个问题以及如何解决它吗?
编辑:始终是无法删除的 crc 文件。
【问题讨论】:
-
我认为,您正试图在您正在阅读的同一文件中写入。
-
您好,谢谢您的回答。我不认为这是可能的。我有: "pathInputFilePath = "C:\\Users\\IdeaProjects\\raw_data\\" "OutputFilePath = "C:\\Users\\IdeaProjects\\prepared_ssp_data\\" 我将csv读入数据框。我不明白它在写作时会如何阅读?
标签: scala apache-spark parquet