gpt4 book ai didi

apache-spark - 如何在HiveContext中设置hive.metastore.warehouse.dir?

转载 作者:行者123 更新时间:2023-12-04 05:23:19 25 4
gpt4 key购买 nike

我正在尝试编写一个依赖DataFrame.saveAsTable()的单元测试用例(因为它由文件系统支持)。我将配置单元仓库参数指向本地磁盘位置:

sql.sql(s"SET hive.metastore.warehouse.dir=file:///home/myusername/hive/warehouse")

默认情况下,应启用Metastore的“嵌入式模式”,因此不需要外部数据库。

但是HiveContext似乎忽略了此配置:因为调用saveAsTable()时仍然出现此错误:
MetaException(message:file:/user/hive/warehouse/users is not a directory or unable to create one)
org.apache.hadoop.hive.ql.metadata.HiveException: MetaException(message:file:/user/hive/warehouse/users is not a directory or unable to create one)
at org.apache.hadoop.hive.ql.metadata.Hive.createTable(Hive.java:619)
at org.apache.spark.sql.hive.HiveMetastoreCatalog.createDataSourceTable(HiveMetastoreCatalog.scala:172)
at org.apache.spark.sql.hive.execution.CreateMetastoreDataSourceAsSelect.run(commands.scala:224)
at org.apache.spark.sql.execution.ExecutedCommand.sideEffectResult$lzycompute(commands.scala:54)
at org.apache.spark.sql.execution.ExecutedCommand.sideEffectResult(commands.scala:54)
at org.apache.spark.sql.execution.ExecutedCommand.execute(commands.scala:64)
at org.apache.spark.sql.SQLContext$QueryExecution.toRdd$lzycompute(SQLContext.scala:1099)
at org.apache.spark.sql.SQLContext$QueryExecution.toRdd(SQLContext.scala:1099)
at org.apache.spark.sql.DataFrame.saveAsTable(DataFrame.scala:1121)
at org.apache.spark.sql.DataFrame.saveAsTable(DataFrame.scala:1071)
at org.apache.spark.sql.DataFrame.saveAsTable(DataFrame.scala:1037)

这很烦人,为什么它仍在发生以及如何解决?

最佳答案

根据http://spark.apache.org/docs/latest/sql-programming-guide.html#sql

Note that the hive.metastore.warehouse.dir property in hive-site.xml is deprecated since Spark 2.0.0. Instead, use spark.sql.warehouse.dir to specify the default location of database in warehouse.

关于apache-spark - 如何在HiveContext中设置hive.metastore.warehouse.dir?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30518130/

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