在 postgresql 中执行 aws_s3.table_import_from_s3 命令时出现 "invalid byte sequence for encoding "UTF8": 0x00" 错误
Getting "invalid byte sequence for encoding "UTF8": 0x00" error when executing aws_s3.table_import_from_s3 command in postgresql
执行时出现以下错误:
SELECT aws_s3.table_import_from_s3( 'test',
'a,b,c,d,e',
'(format csv)',
'abc-ttt-dev',
'outer/inner/Inbound/sample.csv',
'us-east-1'
);
SQL错误[22021]:错误:编码“UTF8”的字节序列无效:0x00
其中:COPY 测试,第 1 行
SQL 语句“从‘/rdsdbdata/extensions/aws_s3/amazon-s3-fifo-6826-20210708T140854Z-0’复制测试 (a,b,c,d,e) 并使用(格式 csv)”
仅供参考,下面的查询工作得很好。
SELECT aws_s3.table_import_from_s3(
'test',
'a,b,d,e',
'DELIMITER ''|''',
'abc-ttt-dev',
'outer/inner/Inbound/sample.txt',
'us-east-1'
);
Table脚本是
CREATE TABLE test (
a text not NULL,
b text not NULL,
c text not NULL,
d text not NULL,
e text not NULL
);
我认为您的 csv 文件中有 NULL 值,这就是您收到此错误的原因。
您可以使用 lambda 预处理文件或参考 Postgres error on insert - ERROR: invalid byte sequence for encoding “UTF8”: 0x00 了解其他解决方法。
执行时出现以下错误:
SELECT aws_s3.table_import_from_s3( 'test',
'a,b,c,d,e',
'(format csv)',
'abc-ttt-dev',
'outer/inner/Inbound/sample.csv',
'us-east-1'
);
SQL错误[22021]:错误:编码“UTF8”的字节序列无效:0x00 其中:COPY 测试,第 1 行 SQL 语句“从‘/rdsdbdata/extensions/aws_s3/amazon-s3-fifo-6826-20210708T140854Z-0’复制测试 (a,b,c,d,e) 并使用(格式 csv)”
仅供参考,下面的查询工作得很好。
SELECT aws_s3.table_import_from_s3(
'test',
'a,b,d,e',
'DELIMITER ''|''',
'abc-ttt-dev',
'outer/inner/Inbound/sample.txt',
'us-east-1'
);
Table脚本是
CREATE TABLE test (
a text not NULL,
b text not NULL,
c text not NULL,
d text not NULL,
e text not NULL
);
我认为您的 csv 文件中有 NULL 值,这就是您收到此错误的原因。
您可以使用 lambda 预处理文件或参考 Postgres error on insert - ERROR: invalid byte sequence for encoding “UTF8”: 0x00 了解其他解决方法。