Hbase Hive 整合映射

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xiewendong93/article/details/54930403

Hbase Hive 整合映射

可使用HQL查询数据

步骤

1,创建Hbase表
2,映射Hive表

步骤一

说明:cf 列簇名,只put了少量测试列
create ‘cofeed_info’,{NAME => ‘cf’, REPLICATION_SCOPE => 1}
put ‘cofeed_info’, ‘100001’, ‘cf:id’, ‘101’
put ‘cofeed_info’, ‘100001’, ‘cf:title’, ‘这是测试用的数据’
put ‘cofeed_info’, ‘100001’, ‘cf:insert_time’, ‘45679848161564’

步骤二

说明:虽然很多列在Hbase表中当前并没有,不过没关系,:key表示rowkey
CREATE EXTERNAL TABLE cofeed_info
(
rowkey string,
id string,
title string,
tourl string,
content string,
data_provider string,
b_class string,
b_catogory string,
source string,
insert_time timestamp,
dt string
) STORED BY ‘org.apache.hadoop.hive.hbase.HBaseStorageHandler’ WITH
SERDEPROPERTIES (“hbase.columns.mapping”=
“:key,
cf:id,
cf:title,
cf:tourl,
cf:content,
cf:data_provider,
cf:b_class,
cf:b_catogory,
cf:source,
cf:insert_time,
cf:dt”) TBLPROPERTIES (“hbase.table.name” = “cofeed_info”);

结果

hive> desc cofeed_info;
OK
rowkey string from deserializer
id string from deserializer
title string from deserializer
tourl string from deserializer
content string from deserializer
data_provider string from deserializer
b_class string from deserializer
b_catogory string from deserializer
source string from deserializer
insert_time timestamp from deserializer
dt string from deserializer
说明:Hbase中没有的列簇为NULL了.
hive> select * from cofeed_info;
OK
100001 101 这是测试用的数据 NULL NULL NULL NULL NULL NULL NULL NULL

猜你喜欢

转载自blog.csdn.net/xiewendong93/article/details/54930403
今日推荐