创建hive整合hbase的表总结

[Author]: kwu 

创建hive整合hbase的表总结。例如以下两种方式:

1、创建hive表的同步创建hbase的表

CREATE  TABLE stage.hbase_news_company_content(key string comment "流水号",
news_id string comment "新闻id",
news_content string comment "文章内容")   
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'   
WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf1:news_id,cf1:news_content")   
TBLPROPERTIES("hbase.table.name" = "news_company_content");

这样的方式创建hive表,删除hive的表。hbase的表的数据也会被删除


2、外表创建hive表整合hbase的表

须要先创建hbase的表:

create 'jsActionPage','cf1'

创建hive的外表

CREATE EXTERNAL TABLE ods.hbase_jsActionPage(key string, bdcCookieId string ,
pcScreenRatio string ,
pageCloseTime string ,
pageLoadCompleteTime string,
pageOpenTime string,
currentURL string)   
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'   
WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf1:bdcCookieId,cf1:pcScreenRatio,
cf1:pageCloseTime,
cf1:pageLoadCompleteTime,
cf1:pageOpenTime,
cf1:currentURL")   
TBLPROPERTIES("hbase.table.name" = "jsActionPage"); 

3、假设往hive整合hbase的表中插入数据

SQL方式:

insert into stage.hbase_news_company_content select a,b,c from stage.tracklog limit 15;


hbase命令

put 'jsActionPage','row1','cf1:time','20150818'



---

相关课程

  1. 数据中台实战课
    ‍ 郭忆 | 构建企业级数据中台
  2. Spark核心原理与实战
    ‍ 吴磊 | 系统掌握Spark大数据处理
  3. Flink核心技术与实战
    ‍ 张利兵 | 深入掌握Flink实时计算框架
posted @ 2017-07-03 16:27  yxysuanfa  阅读(3035)  评论(1)    收藏  举报