简体   繁体   English

Spark作为Hive的引擎

[英]Spark as an engine for Hive

Can we use Spark as an engine for Hive? 我们可以使用Spark作为Hive的引擎吗?

We have many legacy systems and code base in Hive and would like to use Spark with Hive. 我们在Hive中有许多遗留系统和代码库,并且希望将Spark与Hive一起使用。

Best, 最好,

two options, if you want to run hive on spark, it's possible but it's a very alpha feature : https://cwiki.apache.org/confluence/display/Hive/Hive+on+Spark%3A+Getting+Started 两个选项,如果你想在spark上运行配置单元,它是可能的,但它是一个非常alpha功能: https//cwiki.apache.org/confluence/display/Hive/Hive+on+Spark%3A+Getting+Started

IMHO you're better off using Spark SQL and the designated HiveContext, that you can use like that : 恕我直言你最好使用Spark SQL和指定的HiveContext,你可以这样使用:

// sc is an existing SparkContext.
val sqlContext = new org.apache.spark.sql.hive.HiveContext(sc)

sqlContext.sql("CREATE TABLE IF NOT EXISTS src (key INT, value STRING)")
sqlContext.sql("LOAD DATA LOCAL INPATH 'examples/src/main/resources/kv1.txt' INTO TABLE src")

// Queries are expressed in HiveQL
sqlContext.sql("FROM src SELECT key, value").collect().foreach(println)

All in all, I'd suggest you load your Hive tables using Spark SQL and reuse all your Hive queries but through Spark SQL's APIs. 总而言之,我建议您使用Spark SQL加载Hive表,并通过Spark SQL的API重用所有Hive查询。

You can find more informations here : http://spark.apache.org/docs/1.2.0/sql-programming-guide.html 您可以在这里找到更多信息: http//spark.apache.org/docs/1.2.0/sql-programming-guide.html

Does that answer your question ? 这是否回答你的问题 ?

Regards, 问候,

You can execute hive queries on spark execution engine.Hive has a large number of dependencies, these dependencies are not included in the default Spark distribution. 您可以在spark执行引擎上执行配置单元查询.Hive具有大量依赖项,这些依赖项不包含在默认的Spark分发中。 If Hive dependencies can be found on the classpath, Spark will load them automatically. 如果可以在类路径上找到Hive依赖项,Spark将自动加载它们。

You can find the code here: spark-hive-example 你可以在这里找到代码: spark-hive-example

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM