Kettle – ERROR: invalid byte sequence for encoding “UTF8”: 0x00

错误信息:
ERROR: invalid byte sequence for encoding “UTF8”: 0x00

问题原因:
PostgreSQL doesn’t support storing NULL (\0x00) characters in text fields (this is obviously different from the database NULL value, which is fully supported).

Source: http://www.postgresql.org/docs/9.1/static/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS-UESCAPE

If you need to store the NULL character, you must use a bytea field – which should store anything you want, but won’t support text operations on it.

Given that PostgreSQL doesn’t support it in text values, there’s no good way to get it to remove it. You could import your data into bytea and later convert it to text using a special function (in perl or something, maybe?), but it’s likely going to be easier to do that in preprocessing before you load it.

解决方法:
使用transformation目录下的“Replace in string”或者”Value Mapper”组件替换\u0000为其他字符串即可。

Kettle - ERROR: invalid byte sequence for encoding "UTF8": 0x00

注意使用“Replace in string”之后会新出来一个_01字段,mapping里要选择新字段,否则还会报错。

Kettle - ERROR: invalid byte sequence for encoding "UTF8": 0x00

参考:

https://stackoverflow.com/questions/1347646/postgres-error-on-insert-error-invalid-byte-sequence-for-encoding-utf8-0x0

本文作者: GavinDong

版权属于: GavinDong博客

文章链接: https://gavindong.com/2762.html

如果使用过程中遇到问题,可 **点击此处** 交流沟通。

版权所有,转载时必须以链接形式注明作者和原始出处及本声明。

(1)

相关文章

发表回复

登录后才能评论

评论列表(1条)

  • ag的头像
    ag 2019.04.07 08:50

    value mapper只能简单的映射文本,“Replace in string”功能会更强大一些。