为了更方便的查看hbase中的数据,甚至作为一个常规表来查看,可以使用hive进行查看,建表语句如下:
CREATE EXTERNAL TABLE alarm_from_hbase
(
ts string,
alm_time string,
alm_timems int,
tag_nameid string,
alm_type int,
priid int,
alm_ack_time string,
alm_ack_timems int,
alm_group int,
alm_sub_area int,
tag_data_type string,
alm_ack_flg string,
alm_remove_flg string,
alm_remove_time string,
alm_remove_timems int,
alarm_date string
)
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES ('hbase.columns.mapping' = ':key,cf2:alm_time,cf2:alm_timems,cf2:tag_nameid,cf2:alm_type,cf2:priid,cf2:alm_ack_time,cf2:alm_ack_timems,cf2:alm_group,cf2:alm_sub_area,cf2:tag_data_type,cf2:alm_ack_flg,cf2:alm_remove_flg,cf2:alm_remove_time,cf2:alm_remove_timems,cf2:alarm_date')
TBLPROPERTIES ('hbase.table.name' = 'alarm_test');
需要注意hbase中的column family, column。
hbase表数据如下:
查询hive表: