Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redshift COPY - No Errors, 0 Record(s) Loaded Successfully

I'm attempting to COPY a CSV file to Redshift from an S3 bucket. When I execute the command, I don't get any error messages, however the load doesn't work.

Command:

COPY temp FROM 's3://<bucket-redacted>/<object-redacted>.csv'
CREDENTIALS 'aws_access_key_id=<redacted>;aws_secret_access_key=<redacted>'
DELIMITER ',' IGNOREHEADER 1;

Response:

Load into table 'temp' completed, 0 record(s) loaded successfully.

I attempted to isolate the issue via the system tables, but there is no indication there are issues.

Table Definition:

CREATE TABLE temp ("id" BIGINT);

CSV Data:

id
123,
like image 681
king_fink Avatar asked Oct 31 '25 10:10

king_fink


1 Answers

The line endings in your csv file probably don't have a unix new line character at the end, so the COPY command probably sees your file as:

id123,

Given you have the IGNOREHEADER option enabled, and the line endings in the file aren't what COPY is expecting (my assumption based on past experience), the file contents get treated as one line, and then skipped.

I had this occur for some files created from a Windows environment.

I guess one thing to remember is that CSV is not a standard, more a convention, and different products/vendors have different implementations for csv file creation.

like image 123
Adrian Torrie Avatar answered Nov 03 '25 00:11

Adrian Torrie