0
votes

I have two doubts regarding AWS Redshift COPY command when use to load a CSV file from S3. I expected an error in these two conditions but didn't get an error and works fine. So help me to understand the working of COPY command in these conditions:

  1. A required field is empty in CSV.
  2. CSV has more columns than Redshift.
1
What do you mean by "required field"? Did you define the table with a column marked as NOT NULL? Can you show us the definition?John Rotenstein
Yes, I meant required field as NOT NULL column.Mohammed Sherif KK
Loading Default Column Values - Amazon Redshift says: "If COPY attempts to assign NULL to a column that is defined as NOT NULL, the COPY command fails." It might be treating the empty column as a blank string, as opposed to NULL.John Rotenstein

1 Answers

0
votes

Working of COPY command in the above situations:

  1. If the column is VARCHAR or CHAR, the field will be treated as Blank (it's not NULL) and will load the field as-is. If we want to treat blank as null use BLANKSASNULL parameter.
  2. If the table contains fewer columns than the CSV, COPY command will skip the excess columns and load from left.