Spark SQL不允许我创建表,抱怨默认Metastore目录 [英] Spark SQL doesnt let me create a table, complains about default metastore directory

查看:964
本文介绍了Spark SQL不允许我创建表,抱怨默认Metastore目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在本地机器上安装Spark 1.5 spark-1.5.0-bin-hadoop2.6。
Ran $ ./bin/spark-shell
试过,按照
 >rel =nofollow> doc 创建一个表格,作为sqlContext提供的SQL上下文。 
>
>阶> sqlContext.sql(CREATE TABLE IF NOT EXISTS src(key INT,value
> STRING)); 15/09/22 22:18:13错误DDLTask:
> org.apache.hadoop.hive.ql.metadata.HiveException:
> MetaException(消息:file:/ user / hive / warehouse / src不是目录
>或者无法创建一个)在
> org.apache.hadoop.hive.ql.metadata.Hive.createTable(Hive.java:720)

试过为此传递hive参数,但没有奏效:

 > $ ./bin/spark-shell --conf hive.metastore.warehouse.dir =。/警告:
>忽略非spark配置属性:hive.metastore.warehouse.dir = ./

最后尝试了CLI本身,但获得相同的问题。
我在哪里更改配置单元仓库参数位置?



谢谢,
Matt

我没有安装Hadoop,也没有配置。解决方案

元数据的元数据在元数据存储中进行,配置单元上下文增加了对MetaStore中的表的查找的支持。

  import org.apache.spark.sql.hive.HiveContext $ b $ val val hiveContext = new HiveContext(sc)$ b $ val val myDF = sql(select * from mytable)

您将得到dataFrame作为结果

  myDF:org.apache.spark.sql.DataFrame = [.....] 


Installed Spark 1.5 spark-1.5.0-bin-hadoop2.6 on my local machine. Ran $ ./bin/spark-shell Tried, following the doc to create a table, getting this:

> SQL context available as sqlContext.
> 
> scala> sqlContext.sql("CREATE TABLE IF NOT EXISTS src (key INT, value
> STRING)"); 15/09/22 22:18:13 ERROR DDLTask:
> org.apache.hadoop.hive.ql.metadata.HiveException:
> MetaException(message:file:/user/hive/warehouse/src is not a directory
> or unable to create one)  at
> org.apache.hadoop.hive.ql.metadata.Hive.createTable(Hive.java:720)

Tried passing the hive parameter for this, but didnt work:

> $  ./bin/spark-shell --conf hive.metastore.warehouse.dir=./ Warning:
> Ignoring non-spark config property: hive.metastore.warehouse.dir=./

Finally tried the CLI itself, but getting the same issue. Where do i change the hive warehouse parameter location ? I dont have Hadoop installed at the moment, nor hive.

thanks, Matt

解决方案

Metadata of hive tables are strored in metastore, hive context adds support for finding tables in the MetaStore.

import org.apache.spark.sql.hive.HiveContext
val hiveContext = new HiveContext(sc)
val myDF = sql("select * from mytable")

You will get dataFrame as result

myDF: org.apache.spark.sql.DataFrame = [.....]

这篇关于Spark SQL不允许我创建表,抱怨默认Metastore目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆