[英]How to read Hive table with Spark
I would like to read hive table with Spark.我想用 Spark 阅读蜂巢表。 Hive tables data are stored as textFile in
/user/hive/warehouse/problem7.db
. Hive 表数据作为 textFile 存储在
/user/hive/warehouse/problem7.db
。
I do:我愿意:
val warehouseLocation = hdfs://localhost:9000/user/hive/warehouse
// Create the Spark Conf and the Spark Session
val conf = new SparkConf().setAppName("Spark Hive").setMaster("local[2]").set("spark.sql.warehouse.dir", warehouseLocation)
val spark = SparkSession.builder.config(conf).enableHiveSupport().getOrCreate()
val table1 = spark.sql("select * from problem7.categories")
table1.show(false)
I have the following error:我有以下错误:
Table or view not found: `problem7`.`categories`
I resolved in the following way :我通过以下方式解决:
I create a hive-site.xml in spark/conf and add :我在 spark/conf 中创建了一个 hive-site.xml 并添加:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>hive.metastore.uris</name>
<value>thrift://localhost:9083</value>
</property>
</configuration>
then I start hive metastore service with the following command然后我使用以下命令启动 hive Metastore 服务
hive --service metastore
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.