FAQ-Can't export data '\N'

因 RDS 数据库与 HIVE/HDFS 库对空值默认值不一致,直接同步会 RDS 中空值传输至 HIVE 后变成字符串 "NULL",影响后续流程对空值进行判断,可通过以下参数进行转换处理:

RDS -->HIVE/HDFS

--null-string '\\N':将 RDS 库中字符串类字段空值进行转换

--null-non-string '\\N':将 RDS 库中非字符串类字段空值进行转换

eg
sqoop import connect jdbc://mysql:hostname:3306/dbname  --user username --password passwd --null-string '\\N'  --null-non-string '\\N'   --fields-terminated-by '\0001'  --query "select * from tablename  where $CONDITIONS"  --target-dir  /user/warehouse/hive.db/xxx

HIVE/HDFS → RDS

--input-null-string '\\N':声明HIVE/HDFS中字符串空值默认值

--input-null-non-string '\\N':声明HIVE/HDFS中非字符串空值默认值

eg:
sqoop  export  connect jdbc://mysql:hostname:3306/dbname  --user username --password passwd --input-null-string '\\N'  --input-null-non-string '\\N'  --input-fields-terminated-by '\0001'   --query "select * from tablename  where $CONDITIONS"  --target-dir  /user/warehouse/hive.db/xxx