HBase 表上的 SparkSQL

SparkSQL on HBase Tables

有人直接在 HBase 表上使用 SparkSQL,比如在 Hive 表上使用 SparkSQL。 我是新手 spark.Please 指导我如何连接 hbase 和 spark.How 以查询 hbase 表。

据我所知,有两种方法可以连接到 hbase tables

- 直接连接到 Hbase :

直接连接hbase并从RDD创建一个DataFrame并在其上执行SQL。 我不会重新发明轮子,请参阅 How to read from hbase using spark 正如@iMKanchwala 在上面 link 中的回答已经描述了它。唯一的事情就是将其转换为数据帧(使用 toDF)并遵循 sql 方法。

- 使用 hbase 存储处理程序将 table 注册为 hive 外部 table,您可以在 hivecontext 的 spark 上使用 hive。这也是简单的方法。

Ex : 
CREATE TABLE users(
userid int, name string, email string, notes string)
STORED BY 
'org.apache.hadoop.hive.hbase.HBaseStorageHandler' 
WITH SERDEPROPERTIES ( 
"hbase.columns.mapping" = 
”small:name,small:email,large:notes”);

如何做到这一点,请参阅 example

我更喜欢方法 1。

希望对您有所帮助...