1、创建外部表
hive> create external table hive_score (
key string,
name map<string,string>,
class string,
java string,
python string
)
stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
with serdeproperties
("hbase.columns.mapping" =
":key,name:,class:class,course:java,course:python")
tblproperties("hbase.table.name" = "score");
OK
Time taken: 1.73 seconds
hive> select * from hive_score;
OK
610213 {"":"Tom"} 163Cloud NULL 79
610215 {"":"John"} 173BigData 80 86
Time taken: 3.009 seconds, Fetched: 2 row(s)
2、联合创建表
hive> create table hive_hbase(key int, value string)
stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
with serdeproperties ("hbase.columns.mapping" = ":key,cf1:val")
tblproperties ("hbase.table.name" = "xyz");
从test_external导出数据到hive_hbase
hive> insert overwrite table hive_hbase select * from test_external;
hive> select * from hive_hbase;
OK
1 master
2 node1
3 node2
Time taken: 0.263 seconds, Fetched: 3 row(s)
查看HBase表xyz记录
|