incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Petter von Dolwitz (Hem)" <petter.von.dolw...@gmail.com>
Subject Re: Bad Request: Invalid null value for clustering key part
Date Wed, 25 Sep 2013 10:00:08 GMT
I am generating the CSV file by other means than the COPY ... TO command
and I thought that the NULL option did not apply to the COPY ... FROM
command but, as it turns out, it does! This solved my problem.

The documentation here (
http://www.datastax.com/documentation/cql/3.1/webhelp/index.html#cql/cql_reference/copy_r.html)
is misleading. Should I report this by other means than this post?

Thanks,
Petter





2013/9/24 Sylvain Lebresne <sylvain@datastax.com>

> Oh. That would be a COPY thing then. I'm not extremely familiar with cqlsh
> code (which COPY is part of) but looking at the online help for it, it
> seems to have a 'NULL' option that allows to define which character is used
> to represent nulls. And by default, it does is an empty string. So you
> could try something like:
>   COPY ... TO ... WITH NULL='null'
> (assuming that if you do have nulls you use the string 'null' to encode it
> in your csv and that your are sure nothing that's not supposed to be null
> will be represented by the string 'null').
>
> --
> Sylvain
>
>
> On Tue, Sep 24, 2013 at 9:41 AM, Petter von Dolwitz (Hem) <
> petter.von.dolwitz@gmail.com> wrote:
>
>> Hi Sylvain,
>>
>> I was not describing the problem correctly. I'm sorry for this. This is
>> the situation:
>>
>> 1. I'm populating the DB with the java-driver (INSERT INTO...). Some
>> fields that are part of the primary key is *empty strings*. This works fine.
>> 2. I'm trying to populate the DB from a CSV (COPY ... FROM) using cqlsh.
>> Some fields that are part of the primary key is *empty strings*. This
>> scenario gives me the "Bad Request: Invalid null value for clustering key
>> part {field_name}" message. Seems like empty strings are treated as NULL
>> when using the COPY .. FROM command?
>>
>> This can obviously be me not knowing how to encode an empty string in a
>> CSV file. A simplified row from the CSV file can look like below:
>>
>> "field1_value","","","field4_value","field5_value"
>>
>> whereas field1 through field4 is part of the primary key.
>>
>> Thanks for your time,
>> Petter
>>
>>
>>
>>
>> 2013/9/23 Sylvain Lebresne <sylvain@datastax.com>
>>
>>>
>>> Is it not permitted to have null values in a field that is part a
>>>> primary key?
>>>>
>>>
>>> It's not.
>>>
>>>
>>>> This seems to be ok when using the java-driver
>>>>
>>>
>>> Are you sure? Because that would qualify as a bug (in the sense that
>>> it's not supported by C* so there is not reason why this would work with
>>> any driver). If you have some java driver code that show it possible, I'd
>>> be happy to have a look.
>>>
>>> --
>>> Sylvain
>>>
>>
>>
>

Mime
View raw message