hive-to-hbase
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16在hive中建表 create table if not exists employee ( uid int, uname string, age int, sex string, province string ) stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' with serdeproperties( "hbase.columns.mapping"=":key,base_info:name,base_info:age,base_info:sex,address:provice" ) tblproperties( "hbase.table.name"="mydb:employee" );
导入数据
复制代码
1
2
3
4
5
6注意,要使用动态导入数据,不能使用load。 如果想要导入大数据集,可以借助中间表进行动态导入 insert into ..... select ...... from ... 当然:也可以在hbase中直接put数据
hbase-to-hive
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18drop table mydb2.t1; create external table if not exists mydb2.t1( uid string, uage int, uname string, usex string, province string ) stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' with serdeproperties( "hbase.columns.mapping"=":key,f1:age,f1:name,f1:gender,f2:province" ) tblproperties( "hbase.table.name"="ns1:t1" ); 查询 select * from mydb2.t1;
主要事项
复制代码
1
2
3
4
5
61. 映射hbase的列时,要么就写:key,要么不写,默认使用:key 2. hbase中表存在的时候,在hive中创建表时应该使用external关键字。 3. 如果删除了hbase中对应的表数据,那么hive中就不能查询出来数据。 4. hbase中的列和hive中的列个数和数据类型应该尽量相同,hive表和hbase表的字段不是按照名字匹配,而是按照顺序来匹配的。 5. hive、hbase和mysql等可以使用第三方工具来进行整合。
最后
以上就是拼搏花卷最近收集整理的关于HBASE与HIVE转换的全部内容,更多相关HBASE与HIVE转换内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复