spark-sql建表语句限制_Spark SQL不允许我创建表,抱怨默认Metastore目录

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 = [.....]

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值