hbase数据迁移到hive中

描述: 原先数据是存储在hbase中的,但是直接查询hbase速度慢(hbase是宽表结构),所以想把数据迁移到hive中;

1.先hbase 和 hive创建 外部表链接, 可以在hive直接查询;

2.利用创建的外部表,直接在hive中创建内部表;

直接上代码:

#创建hive外部表链接
CREATE
EXTERNAL TABLE hbase_table_hive3( key string, 字段名称 double ) STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,data:字段名称") TBLPROPERTIES("hbase.table.name" = "table_name"); #创建hive内部表 create table table_name as select * from hbase_table_hive3;
#删除中间表
drop table hbase_table_hive3;

猜你喜欢

转载自www.cnblogs.com/smars1990/p/11539677.html