【发布时间】:2015-09-02 20:08:53
【问题描述】:
我有一个 Spark 数据框,我想将其保存为带有分区的 Hive 表。我尝试了以下两个语句,但它们不起作用。我在 HDFS 目录中看不到任何 ORC 文件,它是空的。我可以在 Hive 控制台中看到 baseTable,但显然它是空的,因为 HDFS 中没有文件。
以下两行 saveAsTable() 和 insertInto() 不起作用。 registerDataFrameAsTable() 方法有效,但它在内存表中创建并在我的用例中导致 OOM,因为我有数千个 Hive 分区要处理。我是 Spark 的新手。
dataFrame.write().mode(SaveMode.Append).partitionBy("entity","date").format("orc").saveAsTable("baseTable");
dataFrame.write().mode(SaveMode.Append).format("orc").partitionBy("entity","date").insertInto("baseTable");
//the following works but creates in memory table and seems to be reason for OOM in my case
hiveContext.registerDataFrameAsTable(dataFrame, "baseTable");
【问题讨论】:
-
使用
dataFrame.write().mode(SaveMode.Append).partitionBy("entity","date").format("orc").save("baseTable");并尝试将完整路径放入save(),而不是相对路径。
标签: apache-spark apache-spark-sql