Re: CQL: fails to COPY FROM with null values

2017-06-19 Thread Stefania Alborghetti
It doesn't work because of the white space. By default the NULL value is an
empty string, extra white spaces are not trimmed automatically.

This should work:

ce98d62a-3666-4d3a-ae2f-df315ad448aa,Jonsson,Malcom,,2001-01-19
17:55:17+

You can change the string representing missing values with the NULL option
if you cannot remove spaces from your data.

On Mon, Jun 19, 2017 at 10:10 PM, Tobias Eriksson <
tobias.eriks...@qvantel.com> wrote:

> Hi
>
>  I am trying to copy a file of CSV data into a table
>
> But I get an error since sometimes one of the columns (which is a UUID) is
> empty
>
> Is this a bug or what am I missing?
>
>
>
> Here is how it looks like
>
> Table
>
> id uuid,
>
> lastname text,
>
> firstname text,
>
> address_id uuid,
>
> dateofbirth timestamp,
>
>
>
> PRIMARY KEY (id, lastname, firstname)
>
>
>
> COPY playground.individual(id,lastname,firstname,address_id) FROM
> ‘testfile.csv’;
>
>
>
> Where the testfile.csv is like this
>
>
>
> This works !!!
>
> ce98d62a-3666-4d3a-ae2f-df315ad448aa,Jonsson,Malcom
> ,c9dc8b60-d27f-430c-b960-782d854df3a5,2001-01-19 17:55:17+
>
>
>
> This does NOT work !!!
>
> ce98d62a-3666-4d3a-ae2f-df315ad448aa,Jonsson,Malcom , ,2001-01-19
> 17:55:17+
>
>
>
> Cause then I get the following error
>
> *Failed to import 1 rows: ParseError - badly formed hexadecimal UUID
> string,  given up without retries*
>
>
>
> So, how do I import my CSV file and set the columns which does not have a
> UUID to null ?
>
>
>
> -Tobias
>



-- 



STEFANIA ALBORGHETTI

Software engineer | +852 6114 9265 | stefania.alborghe...@datastax.com


[image: http://www.datastax.com/cloud-applications]



CQL: fails to COPY FROM with null values

2017-06-19 Thread Tobias Eriksson
Hi
 I am trying to copy a file of CSV data into a table
But I get an error since sometimes one of the columns (which is a UUID) is empty
Is this a bug or what am I missing?

Here is how it looks like
Table
id uuid,
lastname text,
firstname text,
address_id uuid,
dateofbirth timestamp,

PRIMARY KEY (id, lastname, firstname)

COPY playground.individual(id,lastname,firstname,address_id) FROM 
‘testfile.csv’;

Where the testfile.csv is like this

This works !!!
ce98d62a-3666-4d3a-ae2f-df315ad448aa,Jonsson,Malcom 
,c9dc8b60-d27f-430c-b960-782d854df3a5,2001-01-19 17:55:17+

This does NOT work !!!
ce98d62a-3666-4d3a-ae2f-df315ad448aa,Jonsson,Malcom , ,2001-01-19 17:55:17+

Cause then I get the following error
Failed to import 1 rows: ParseError - badly formed hexadecimal UUID string,  
given up without retries

So, how do I import my CSV file and set the columns which does not have a UUID 
to null ?

-Tobias