hive与hbase数据类型对应关系
当hbase中double,int 类型以byte方式存储时,用字符串取出来必然是乱码。
在hivd与hbase整合时也遇到这个问题:做法是:#b
1.加#b
CREATE EXTERNAL TABLE hivebig (key string,CUST_NAME string,PHONE_NUM int,BRD_WORK_FLUX double)
STORED BY ‘org.apache.hadoop.hive.hbase.HBaseStorageHandler‘
WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,bd:CUST_NAME,bd:PHONE_NUM#b,bd:BRD_WORK_FLUX#b")
TBLPROPERTIES ("hbase.table.name" = "bigtable2");
2.不加#b时,hive shell读取出来是乱码
CREATE EXTERNAL TABLE hivebig (key string,CUST_NAME string,PHONE_NUM int,BRD_WORK_FLUX double)
STORED BY ‘org.apache.hadoop.hive.hbase.HBaseStorageHandler‘
WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,bd:CUST_NAME,bd:PHONE_NUM,bd:BRD_WORK_FLUX")
TBLPROPERTIES ("hbase.table.name" = "bigtable2");
select * FROM hivebig;
select * FROM hivebig where PHONE_NUM > 1;
select * FROM hivebig where BRD_WORK_FLUX > 1555;
cf:val#s 中的#s就表示类型为string,cf:foo没有配置类型,则采用hbase.table.default.storage.type的配置,#b为binary