创建数据库
create database ods_feature
在hive 中创建表
create external table ods_feature.ods_users(
userid string,
locale string,
birthyear string,
gender string,
joinedAt string,
location string,
timezone string
)
stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
with serdeproperties ("hbase.columns.mapping"=":key,base:locale,base:birthyear,base:gender,base:joinedAt,base:location,base:timezone")
tblproperties ("hbase.table.name"="exps:hbase_users")
1)创建hive的外部表
2)stored by指定数据的存储方式
3)SERDEPROPERTIES:表示字段映射,对应hive中的表字段的顺序,需要注意的是 :key指的是Hbase中的rowdy,hive表中要有一个key字段与之对应,否则会报错的。
4)TBLPROPERTIES:表示表名映射,指定需要映射的Hbase表名。