You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by "Ryabin, Thomas" <Th...@McKesson.com> on 2012/10/19 18:53:40 UTC

DELETE query failing in CQL 3.0

I have a column family called "books", and am trying to delete all rows where the "title" column is equal to "hatchet". This is the query I am using:
    DELETE FROM books WHERE title = 'hatchet';

This query is failing with this error:
    Bad Request: PRIMARY KEY part title found in SET part

I am using Cassandra 1.1 and CQL 3.0. What could be the problem?

-Thomas

Re: DELETE query failing in CQL 3.0

Posted by Tyler Hobbs <ty...@datastax.com>.
For what it's worth, Cassandra 1.2 will support deleting a slice of
columns, allowing you to specify the first N components of the primary key
in a WHERE clause for a DELETE statement:
https://issues.apache.org/jira/browse/CASSANDRA-3708

On Mon, Oct 22, 2012 at 8:45 AM, Ryabin, Thomas
<Th...@mckesson.com>wrote:

>  I figured out the problem. The DELETE query only works if the column
> used in the WHERE clause is also the first column used to define the
> PRIMARY KEY.****
>
> ** **
>
> -Thomas****
>
> ** **
>
> *From:* wang liang [mailto:wlahhn@gmail.com]
> *Sent:* Monday, October 22, 2012 1:31 AM
> *To:* user@cassandra.apache.org
> *Subject:* Re: DELETE query failing in CQL 3.0****
>
> ** **
>
> It is better to provide table definition. I guess the reason is below
> statement. ****
>
> " a table must define at least one column that is not part of the PRIMARY
> KEY as a row exists in Cassandra only if it contains at least one value for
> one such column "****
>
> Please check this document here<http://cassandra.apache.org/doc/cql3/CQL.html#createKeyspaceStmt>
> . ****
>
> ** **
>
> On Mon, Oct 22, 2012 at 7:53 AM, aaron morton <aa...@thelastpickle.com>
> wrote:****
>
> Can you paste the table definition ? ****
>
> ** **
>
> Thanks****
>
> ** **
>
> -----------------****
>
> Aaron Morton****
>
> Freelance Developer****
>
> @aaronmorton****
>
> http://www.thelastpickle.com****
>
> ** **
>
> On 20/10/2012, at 5:53 AM, "Ryabin, Thomas" <Th...@McKesson.com>
> wrote:****
>
>
>
> ****
>
> I have a column family called “books”, and am trying to delete all rows
> where the “title” column is equal to “hatchet”. This is the query I am
> using:****
>
>     DELETE FROM books WHERE title = ‘hatchet’;****
>
>  ****
>
> This query is failing with this error:****
>
>     Bad Request: PRIMARY KEY part title found in SET part****
>
>  ****
>
> I am using Cassandra 1.1 and CQL 3.0. What could be the problem?****
>
>  ****
>
> -Thomas****
>
> ** **
>
>
>
> ****
>
> ** **
>
> --
> Best wishes,
> Helping others is to help myself.****
>



-- 
Tyler Hobbs
DataStax <http://datastax.com/>

RE: DELETE query failing in CQL 3.0

Posted by "Ryabin, Thomas" <Th...@McKesson.com>.
I figured out the problem. The DELETE query only works if the column used in the WHERE clause is also the first column used to define the PRIMARY KEY.

-Thomas

From: wang liang [mailto:wlahhn@gmail.com]
Sent: Monday, October 22, 2012 1:31 AM
To: user@cassandra.apache.org
Subject: Re: DELETE query failing in CQL 3.0

It is better to provide table definition. I guess the reason is below statement.
" a table must define at least one column that is not part of the PRIMARY KEY as a row exists in Cassandra only if it contains at least one value for one such column "
Please check this document here<http://cassandra.apache.org/doc/cql3/CQL.html#createKeyspaceStmt>.

On Mon, Oct 22, 2012 at 7:53 AM, aaron morton <aa...@thelastpickle.com>> wrote:
Can you paste the table definition ?

Thanks

-----------------
Aaron Morton
Freelance Developer
@aaronmorton
http://www.thelastpickle.com

On 20/10/2012, at 5:53 AM, "Ryabin, Thomas" <Th...@McKesson.com>> wrote:


I have a column family called "books", and am trying to delete all rows where the "title" column is equal to "hatchet". This is the query I am using:
    DELETE FROM books WHERE title = 'hatchet';

This query is failing with this error:
    Bad Request: PRIMARY KEY part title found in SET part

I am using Cassandra 1.1 and CQL 3.0. What could be the problem?

-Thomas




--
Best wishes,
Helping others is to help myself.

Re: DELETE query failing in CQL 3.0

Posted by wang liang <wl...@gmail.com>.
It is better to provide table definition. I guess the reason is below
statement.
" a table must define at least one column that is not part of the PRIMARY
KEY as a row exists in Cassandra only if it contains at least one value for
one such column "
Please check this document
here<http://cassandra.apache.org/doc/cql3/CQL.html#createKeyspaceStmt>
.

On Mon, Oct 22, 2012 at 7:53 AM, aaron morton <aa...@thelastpickle.com>wrote:

> Can you paste the table definition ?
>
> Thanks
>
>   -----------------
> Aaron Morton
> Freelance Developer
> @aaronmorton
> http://www.thelastpickle.com
>
> On 20/10/2012, at 5:53 AM, "Ryabin, Thomas" <Th...@McKesson.com>
> wrote:
>
> I have a column family called “books”, and am trying to delete all rows
> where the “title” column is equal to “hatchet”. This is the query I am
> using:****
>     DELETE FROM books WHERE title = ‘hatchet’;****
> ** **
> This query is failing with this error:****
>     Bad Request: PRIMARY KEY part title found in SET part****
> ** **
> I am using Cassandra 1.1 and CQL 3.0. What could be the problem?****
> ** **
> -Thomas****
>
>
>


-- 
Best wishes,
Helping others is to help myself.

Re: DELETE query failing in CQL 3.0

Posted by aaron morton <aa...@thelastpickle.com>.
Can you paste the table definition ? 

Thanks

-----------------
Aaron Morton
Freelance Developer
@aaronmorton
http://www.thelastpickle.com

On 20/10/2012, at 5:53 AM, "Ryabin, Thomas" <Th...@McKesson.com> wrote:

> I have a column family called “books”, and am trying to delete all rows where the “title” column is equal to “hatchet”. This is the query I am using:
>     DELETE FROM books WHERE title = ‘hatchet’;
>  
> This query is failing with this error:
>     Bad Request: PRIMARY KEY part title found in SET part
>  
> I am using Cassandra 1.1 and CQL 3.0. What could be the problem?
>  
> -Thomas