Apache Spark SQLContext 与 HiveContext 有什么区别? [英] What is the difference between Apache Spark SQLContext vs HiveContext?

查看:31
本文介绍了Apache Spark SQLContext 与 HiveContext 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Apache Spark SQLContext 和 HiveContext 有什么区别?

What are the differences between Apache Spark SQLContext and HiveContext ?

一些消息来源说,由于 HiveContext 是 SQLContext 的超集,开发人员应该始终使用比 SQLContext 具有更多功能的 HiveContext.但是目前各个上下文的API大体相同.

Some sources say that since the HiveContext is a superset of SQLContext developers should always use HiveContext which has more features than SQLContext. But the current APIs of each contexts are mostly same.

  • SQLContext/HiveContext 在哪些场景中更有用?.
  • HiveContext 是否仅在使用 Hive 时更有用?.
  • 或者 SQLContext 是使用 Apache Spark 实现大数据应用程序的全部需要吗?

推荐答案

Spark 2.0+

Spark 2.0 提供了原生窗口函数(SPARK-8641)并具有一些特性解析方面的额外改进和更好的 SQL 2003 合规性,因此它对 Hive 实现核心功能的依赖显着减少,并且由于 HiveContext(SparkSession 与 Hive 支持)似乎是稍微不那么重要.

Spark 2.0 provides native window functions (SPARK-8641) and features some additional improvements in parsing and much better SQL 2003 compliance so it is significantly less dependent on Hive to achieve core funcionality and because of that HiveContext (SparkSession with Hive support) seems to be slightly less important.

火花<2.0

显然,如果您想使用 Hive,您必须使用 HiveContext.除此之外,目前(Spark 1.5)最大的区别是支持 窗口函数 和访问 Hive UDF 的能力.

Obviously if you want to work with Hive you have to use HiveContext. Beyond that the biggest difference as for now (Spark 1.5) is a support for window functions and ability to access Hive UDFs.

总的来说,窗口函数是一个非常酷的特性,可以用来以简洁的方式解决相当复杂的问题,而无需在 RDD 和 DataFrame 之间来回切换.性能仍然远未达到最佳状态,尤其是没有 PARTITION BY 子句,但它实际上并不是 Spark 特有的.

Generally speaking window functions are a pretty cool feature and can be used to solve quite complex problems in a concise way without going back and forth between RDDs and DataFrames. Performance is still far from optimal especially without PARTITION BY clause but it is really nothing Spark specific.

关于 Hive UDF 现在不是一个严重的问题,但在 Spark 1.5 之前,许多 SQL 函数已经使用 Hive UDF 表达并且需要 HiveContext 才能工作.

Regarding Hive UDFs it is not a serious issue now, but before Spark 1.5 many SQL functions have been expressed using Hive UDFs and required HiveContext to work.

HiveContext 还提供了更强大的 SQL 解析器.参见示例:py4j.protocol.Py4JJavaError when select Nested column in dataframe using select statement

HiveContext also provides more robust SQL parser. See for example: py4j.protocol.Py4JJavaError when selecting nested column in dataframe using select statetment

最后需要 HiveContext 来启动 Thrift 服务器.

Finally HiveContext is required to start Thrift server.

HiveContext 最大的问题是它有大量的依赖.

The biggest problem with HiveContext is that it comes with large dependencies.

这篇关于Apache Spark SQLContext 与 HiveContext 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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