昨夜下班之前,开发人员发现了HIVE/HBaes集成的一个BUG,这个发现过程折腾了半天,真是一个无厘头的加班夜
假如HBase 表结构如下:
table name : 'testtable'
column family : 'data'
column 1 : 'name'
column 2 : 'color'
HIVE映射的表结构如下:
table name : 'hb_testtable'
column 1 : 'name'
column 2 : 'color'
在hbase中放入两条记录
James, blue
May
然后在Hive上执行:
select * from hb_testtable where color is null
结果很正常
May, NULL
然后试一下count
select count( * ) from hb_testtable where color is null
结果为0, 应该为1
这对于一些统计来说,会造成数据不准
所以,为了绕过这个BUG,HBase中插入记录时,如果为空,也需要插入一个空字符串。