HBase與Hive的整合案例二
阿新 • • 發佈:2018-11-14
1.案例需求
在 HBase 中已經儲存了某一張表hbase_hive,然後在Hive中建立一個外部表來關聯HBase中的hbase_hive這張表,使之可以藉助 Hive來分析 HBase 這張表中的資料,案例二是緊接著案例一進行的,所以在做案例二之前應該先進行案例一
2.在Hive中建立外部表並關聯到HBase中的表
CREATE EXTERNAL TABLE hbase_emp( empno int, ename string, job string, mgr int, hiredate string, sal double, comm double, deptno int) STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,info:ename,info:job,info:mgr,info:hiredate,info:sal,info:comm,info:deptno") TBLPROPERTIES ("hbase.table.name" = "hbase_hbase");
3.檢視是否關聯成功
select *from hbase_emp;
關聯成功後就可以使用Hive來進行一些分析操作了