handling numeric null values using copy command in amazon redshift

Kumar Pushkar

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

denismo

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';

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Amazon RedShift Copy Command

From Dev

Is 'copy' command in Amazon RedShift atomic or not?

From Dev

Where to run the copy command for Amazon Redshift

From Dev

amazon redshift copy command json format

From Dev

Handling null values in Command.ExecuteScalar using C#

From Dev

Copy data from a JSON file to Redshift using the COPY command

From Dev

Redshift COPY command with "^A" delimiter

From Dev

Redshift COPY command delimiter not found

From Dev

Ways to create a copy of an existing Database in Amazon Redshift

From Dev

Ways to create a copy of an existing Database in Amazon Redshift

From Dev

Uploading data to RedShift using COPY

From Dev

Calculate the variation of values in amazon redshift database

From Dev

Handling NULL values in Hive

From Dev

Handling null values in protobuffers

From Dev

Handling of Null Values

From Dev

Handling null values on hive

From Dev

Use Redshift Copy command to do a merge

From Dev

Redshift COPY command for Parquet format with Snappy compression

From Dev

using ismember for numeric values

From Dev

How to connect to a cluster in Amazon Redshift using SQLAlchemy?

From Dev

Oracle SQL for handling null values

From Dev

Handling NULL values in Spark StringIndexer

From Dev

Syntax for handling null values nicely

From Dev

Handling null values with PowerShell dates

From Dev

Merge multiple lines with non null values in Redshift

From Dev

How to insert NULL values from Spark into Redshift?

From Dev

copy command using JS

From Dev

Classification using KNN with numeric values

From Dev

Classification using KNN with numeric values