while trying to load data to redshift using s3 I am getting an error
Invalid digit, Value 'N', Pos 0, Type: Decimal
its failing while trying to load NULL value to a numeric datatype column (column is nullable)
although i am using NULL AS '\000' conversion.
COPY campaign
FROM 's3://test/campaign.csv'
credentials '------------------'
EMPTYASNULL
NULL AS '\000'
delimiter ','
region '----';
how can we handle such scenarios?
Table:
CREATE TABLE campaign (
name VARCHAR(255) SORTKEY NOT NULL,
discount_med DECIMAL(5,2),
discount_packages DECIMAL(5,2),
discount_test DECIMAL(5,2)
);
Sample input:
test1,5.25,NULL,1
Simply use null , eg INSERT INTO t(a, b) SELECT 1, null; . Adding quotes around it makes it a text value.
The simplest COPY command uses the following format. COPY table-name FROM data-source authorization; The following example creates a table named CATDEMO, and then loads the table with sample data from a data file in Amazon S3 named category_pipe. txt .
Instead of NULL AS '\000'
use NULL as 'NULL'
. This worked for me on your table and data:
COPY campaign
FROM 's3://denis-stackoverflow/campaign.csv'
credentials '---'
NULL AS 'NULL'
EMPTYASNULL
delimiter ','
region 'ap-southeast-2';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With