hive某个字段中包括\n(和换行符冲突)

用spark执行SQL保存到Hive中:

 hiveContext.sql("insert overwrite table test select * from aaa")

执行完成,没报错,但是核对结果的时候,发现有几笔数据超出指定范围(实际只包含100/200)
在这里插入图片描述
最终排查到是ret_pay_remark 字段包含换行符,解决方案:执行SQL中把特殊字符替换掉

regexp_replace(ret.pay_remark, '\n|\t|\r', '')              ret_pay_remark    

猜你喜欢

转载自blog.csdn.net/lhxsir/article/details/84374203