9.Apache Hive 映射Hbase表 出现数据重复

一、问题

在hive中创建一个映射hbase的外部表,用来查询hbase的数据。查询hive外部表时发现数据重复。
hbase中的建表语句如下:

create 'hbase_table_name',{NAME=>'0',VERSIONS=>1,BLOCKCACHE=>true,BLOOMFILTER=>'ROW',COMPRESSION=>'SNAPPY'},{SPLITS => ['0','1','2','3','4','5','6','7','8','9']}

hive创建的外部表sql如下:

CREATE external TABLE hive_table_name(rowkey binary, col string ) 
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES (
"hbase.columns.mapping" = ":key,0:col"
)
tblproperties ("hbase.table.name" = "hbase_table_name", "hbase.mapred.output.outputtable" = "hbase_table_name","");

二、解决

1 修改hbase存储格式为binary

修改hive建表语句为如下

CREATE external TABLE hive_table_name(rowkey binary, col string ) 
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES (
"hbase.columns.mapping" = ":key,0:col"
)
tblproperties ("hbase.table.name" = "hbase_table_name", "hbase.mapred.output.outputtable" = "hbase_table_name","hbase.table.default.storage.type" = "binary");

2 重新建hive表

再查询发现数据已经不重复了

反思

没有搞清楚具体原理,猜测是类型映射问题导致的

参考链接

博客 : https://blog.csdn.net/hai19850514/article/details/84465279

hive官方文档: https://cwiki.apache.org/confluence/display/Hive/HBaseIntegration

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值