Spark SQL 是否使用 Hive Metastore? [英] Does Spark SQL use Hive Metastore?

查看:54
本文介绍了Spark SQL 是否使用 Hive Metastore?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个 Spark SQL 应用程序,但我有几个问题:

I am developing a Spark SQL application and I've got few questions:

  1. 我读到 Spark-SQL 在幕后使用 Hive Metastore?这是真的?我说的是一个纯 Spark-SQL 应用程序,它没有显式连接到任何 Hive 安装.
  2. 我正在启动一个 Spark-SQL 应用程序,不需要使用 Hive.有什么理由使用 Hive 吗?据我了解,Spark-SQL 比 Hive 快得多;所以,我看不出有任何理由使用 Hive.但我说得对吗?

推荐答案

我读到 Spark-SQL 在幕后使用 Hive Metastore?这是真的?我说的是一个纯 Spark-SQL 应用程序,它没有显式连接到任何 Hive 安装.

I read that Spark-SQL uses Hive metastore under the cover? Is this true? I'm talking about a pure Spark-SQL application that does not explicitly connect to any Hive installation.

Spark SQL 在幕后不使用 Hive 元存储(并且默认为 in-memory 非 Hive 目录,除非您在 spark-shell 中执行对面).

Spark SQL does not use a Hive metastore under the covers (and defaults to in-memory non-Hive catalogs unless you're in spark-shell that does the opposite).

默认的外部目录实现由 spark.sql.catalogImplementation 内部属性控制,可以是两个可能的值之一:hivein-memory.

The default external catalog implementation is controlled by spark.sql.catalogImplementation internal property and can be one of the two possible values: hive and in-memory.

使用 SparkSession 了解正在使用的目录.

Use the SparkSession to know what catalog is in use.

scala> :type spark
org.apache.spark.sql.SparkSession

scala> spark.version
res0: String = 2.4.0

scala> :type spark.sharedState.externalCatalog
org.apache.spark.sql.catalyst.catalog.ExternalCatalogWithListener

scala> println(spark.sharedState.externalCatalog.unwrapped)
org.apache.spark.sql.hive.HiveExternalCatalog@49d5b651

请注意,我使用了 spark-shell 来启动 Hive-aware SparkSession,所以我必须用 --conf spark.sql 启动它.catalogImplementation=in-memory 将其关闭.

Please note that I used spark-shell that does start a Hive-aware SparkSession and so I had to start it with --conf spark.sql.catalogImplementation=in-memory to turn it off.

我正在启动一个 Spark-SQL 应用程序,不需要使用 Hive.有什么理由使用 Hive 吗?据我了解,Spark-SQL 比 Hive 快得多;所以,我看不出有任何理由使用 Hive.

I am starting a Spark-SQL application, and have no need to use Hive. Is there any reason to use Hive? From what I understand Spark-SQL is much faster than Hive; so, I don't see any reason to use Hive.

这是一个非常有趣的问题,可以有不同的答案(有些甚至主要基于意见,所以我们必须格外小心并遵循 StackOverflow 规则).

That's a very interesting question and can have different answers (some even primarily opinion-based so we have to be extra careful and follow the StackOverflow rules).

是否有任何理由使用 Hive?

Is there any reason to use Hive?

没有

但是...如果您想使用 Spark 2.2 的最新功能,即基于成本的优化器,您可能需要将其视为用于成本统计的 ANALYZE TABLE 可能相当昂贵并且因此,对在不同 Spark 应用程序运行中反复使用的表执行一次可以提高性能.

But...if you want to use the very recent feature of Spark 2.2, i.e. cost-based optimizer, you may want to consider it as ANALYZE TABLE for cost statistics can be fairly expensive and so doing it once for tables that are used over and over again across different Spark application runs could give a performance boost.

请注意,没有 Hive 的 Spark SQL 也可以这样做,但有一些限制,因为本地默认元存储仅用于单用户访问,并且无法跨同时提交的 Spark 应用程序重用元数据.

Please note that Spark SQL without Hive can do it too, but have some limitation as the local default metastore is just for a single-user access and reusing the metadata across Spark applications submitted at the same time won't work.

我看不出有任何理由使用 Hive.

I don't see any reason to use Hive.

我写了一篇博文 为什么 Spark SQL 对 Hive 如此痴迷?!(在使用 Hive 仅仅一天之后) 在那里我问了一个类似的问题,令我惊讶的是,直到现在(在我于 2016 年 4 月 9 日发布博客文章后将近一年),我想我可能已经明白为什么了Hive Metastore 的概念非常重要,尤其是.在多用户 Spark 笔记本环境中.

I wrote a blog post Why is Spark SQL so obsessed with Hive?! (after just a single day with Hive) where I asked a similar question and to my surprise it's only now (almost a year after I posted the blog post on Apr 9, 2016) when I think I may have understood why the concept of Hive metastore is so important, esp. in multi-user Spark notebook environments.

Hive 本身只是 HDFS 上的一个数据仓库,所以如果你有 Spark SQL,用处不大,但仍有一些 Hive 做得相当好的概念在 Spark SQL 中很有用(直到它完全站在它的拥有类似 Hive 的 Metastore 的腿).

Hive itself is just a data warehouse on HDFS so not much use if you've got Spark SQL, but there are still some concepts Hive has done fairly well that are of much use in Spark SQL (until it fully stands on its own legs with a Hive-like metastore).

这篇关于Spark SQL 是否使用 Hive Metastore?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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