当前位置: 移动技术网 > IT编程>数据库>Oracle > Sqoop将数据从oracle导入到hive时,数据错位的问题解决

Sqoop将数据从oracle导入到hive时,数据错位的问题解决

2018年09月13日  | 移动技术网IT编程  | 我要评论

在使用sqoop将数据从oracle导入hive时,对数据进行验证,发现hive中的数据比oracle的多,然后发现多出来的数据严重错位,大量字段为null

怀疑是某些字段含有了hive默认的分隔符,如“\n”,“\r”,“\01”

解决办法是增加参数--hive-drop-import-delims来解决

hive will have problems using sqoop-imported data if your database’s rows contain string fields that have hive’s default row delimiters (\nand\rcharacters) or column delimiters (\01characters) present in them. you can use the--hive-drop-import-delimsoption to drop those characters on import to give hive-compatible text data. alternatively, you can use the--hive-delims-replacementoption to replace those characters with a user-defined string on import to give hive-compatible text data. these options should only be used if you use hive’s default delimiters and should not be used if different delimiters are specified.

可以从中看出,“\n”、“\r”是hive默认的行分隔符,而“\01”则是hive默认的列分隔符,如果数据中含有这些分隔符,在不处理的情况下,hive就会对数据进行错误的分割,造成数据错位以及数据增多的问题,解决办法就是

第一种,使用--hive-drop-import-delims 来去除这些字符

第二种,使用--hive-delims-replacement来替换这些字符

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网