无法使用 Spark 合并小型 ORC 文件

Unable to Merge Small ORC Files using Spark

我有一个外部 ORC table,里面有大量的小文件,这些文件每天都来自源。我需要将这些文件合并成更大的文件。

我尝试将 ORC 文件加载到 spark 并使用覆盖方法保存

val fileName = "/user/db/table_data/"  //This table contains multiple partition on date column with small data files.
val df = hiveContext.read.format("orc").load(fileName)
df.repartition(1).write.mode(SaveMode.Overwrite).partitionBy("date").orc("/user/db/table_data/)

但是mode(SaveMode.Overwrite) 正在从 HDFS 中删除所有数据。当我尝试不使用 mode(SaveMode.Overwrite) 方法时,它抛出错误文件已经存在。

有人可以帮我继续吗?

按照@Avseiytsev 的建议,我将合并的 orc 文件作为 HDFS 中的源存储在不同的文件夹中,并在作业完成后将数据移动到 table 路径。