1

I am getting below error when executing :

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 Error [22021]: ERROR: invalid byte sequence for encoding "UTF8": 0x00 Where: COPY test, line 1 SQL statement "copy test (a,b,c,d,e) from '/rdsdbdata/extensions/aws_s3/amazon-s3-fifo-6826-20210708T140854Z-0' with (format csv)"

Just for information, Below query works perfectly fine.

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 script is

CREATE TABLE test (
    a text not NULL,
    b text not NULL,
    c text not NULL,
    d text not NULL,
    e text not NULL
);
Manish Nankar
  • 37
  • 1
  • 8

1 Answers1

0

I think there are NULL values in your csv file and that is the reason you get this error.

You can either pre process the file using lambda or refer to Postgres error on insert - ERROR: invalid byte sequence for encoding “UTF8”: 0x00 for other workarounds.

Naman
  • 296
  • 1
  • 10