Return-Path: X-Original-To: apmail-cassandra-user-archive@www.apache.org Delivered-To: apmail-cassandra-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4B28410A5A for ; Tue, 24 Sep 2013 08:42:20 +0000 (UTC) Received: (qmail 16545 invoked by uid 500); 24 Sep 2013 08:42:15 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 16493 invoked by uid 500); 24 Sep 2013 08:42:12 -0000 Mailing-List: contact user-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cassandra.apache.org Delivered-To: mailing list user@cassandra.apache.org Received: (qmail 16481 invoked by uid 99); 24 Sep 2013 08:42:11 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Sep 2013 08:42:11 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS,WEIRD_QUOTING X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of sylvain@datastax.com designates 209.85.192.179 as permitted sender) Received: from [209.85.192.179] (HELO mail-pd0-f179.google.com) (209.85.192.179) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Sep 2013 08:42:07 +0000 Received: by mail-pd0-f179.google.com with SMTP id v10so4296053pde.38 for ; Tue, 24 Sep 2013 01:41:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=ZYh++qLLNpF9OpptE608DiEY75r8GWcQbZfLxOMVWbc=; b=eoOHg3+YXDw49hkpdMuCbSxCsp6+AW0fFp+yNJbDQs17h+GY6delkxhYcSM5dbzAEo GCNkZXICnJz0rkeDim/6q9nQn8CjtwH7RgwPOUH6lFVtGPDRK6nR5x9R0R9kyRGktjvx 90WrinA2bXZ5qMUQiSB5Jf76UlhfJJQkbUm+0YoR0/V3ACVybZd6ZaHQ0ZdGE7vR1tun VQHW8JuAXd8LEyQfXoEGuGLxVorCzkFOUlJlBgt2ktUITV2Y4lpwL5F7tOUOwW1ZvRjC 5i1bazPL30UJt8NVOvCQ2Y6MQD0hB0GrP//mhcyT0SDyeX8BaecEvX8x10D16l3gDVly 1G+A== X-Gm-Message-State: ALoCoQn5hiXmuH/cFgatwtx+BC3MfAF47jciCz7Z3uvtrFalP4OzudeivU2q0OVBHzLPGqyFe56Y MIME-Version: 1.0 X-Received: by 10.66.66.161 with SMTP id g1mr3930104pat.175.1380012106845; Tue, 24 Sep 2013 01:41:46 -0700 (PDT) Received: by 10.68.51.1 with HTTP; Tue, 24 Sep 2013 01:41:46 -0700 (PDT) In-Reply-To: References: Date: Tue, 24 Sep 2013 10:41:46 +0200 Message-ID: Subject: Re: Bad Request: Invalid null value for clustering key part From: Sylvain Lebresne To: "user@cassandra.apache.org" Content-Type: multipart/alternative; boundary=001a1134a3186a32c404e71d1b44 X-Virus-Checked: Checked by ClamAV on apache.org --001a1134a3186a32c404e71d1b44 Content-Type: text/plain; charset=ISO-8859-1 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 > >> >> 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 >> > > --001a1134a3186a32c404e71d1b44 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
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 defin= e which character is used to represent nulls. And by default, it does is an= empty string. So you could try something like:
=A0 COPY ... TO ... WITH NULL=3D'null'
(assuming that if = you do have nulls you use the string 'null' to encode it in your cs= v 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, Pet= ter von Dolwitz (Hem) <petter.von.dolwitz@gmail.com> wrote:
Hi Sylvain,

I was not describing the problem correctly. I&#= 39;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 wo= rks 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*. Th= is scenario gives me the "Bad Request: Invalid null value for clusteri= ng key part {field_name}" message. Seems like empty strings are treate= d as NULL when using the COPY .. FROM command?

This can obviously be me not knowing how to encode an empty strin= g in a CSV file. A simplified row from the CSV file can look like below:
"field1_value","","","field4_value&= quot;,"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 permitt= ed to have null values in a field that is part a primary key?

It's not.
= =A0
This seems to= be ok when using the java-driver

Are you sure? Because that wou= ld qualify as a bug (in the sense that it's not supported by C* so ther= e 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


--001a1134a3186a32c404e71d1b44--