Hive表字段不区分大小写
表字段,表名都不区分。本来挺好的,但是采取外部映射表时就麻烦了,对不上。
我这使用的是hive外部表直接映射mongodb的bson文件。mongodb的字段是大写,但是我把表建好以后,所有字段中有大写字母的值全是空。
这是因为hive用全小写映射bson的字段,匹配不上,自然就为空。所以在建表语句后面一定要加上字段mapping,比如下面这个例子:
create table mongodb.m_MemberSobotTicketCreateSnapShot(
id string,
province string,
city string,
isp string,
member map<string,string>,
device_info map<string,string>,
extendFields map<string,string>,
client_type int,
client_version string,
ticketLevel int,
ticketContent string,
remote_addr string,
ticketTitle string,
source int,
ticketStatus int,
ticketTypeId string,
ticketStartWay int,
time int
)
row format serde 'com.mongodb.hadoop.hive.BSONSerDe'
with serdeproperties(
'mongo.columns.mapping'='{\"id\":\"_id\", \"extendfields\":\"extendFields\", \"ticketlevel\":\"ticketLevel\", \"ticketcontent\":\"ticketContent\", \"tickettitle\":\"ticketTitle\", \"ticketstatus\":\"ticketStatus\", \"tickettypeId\":\"ticketTypeId\"}')
stored as inputformat 'com.mongodb.hadoop.mapred.BSONFileInputFormat'
outputformat 'com.mongodb.hadoop.hive.output.HiveBSONFileOutputFormat'
location '/mongobak/MemberSobotTicketCreateSnapShot';