Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

com.datastax.driver.core.exceptions.InvalidQueryException: PRIMARY KEY part sequence found in SET part

Tags:

cassandra

cql

I am trying to update the table, then i am getting this exception:

com.datastax.driver.core.exceptions.InvalidQueryException: PRIMARY KEY part sequence found in SET part.

My table structure is

CREATE TABLE IF NOT EXISTS STYLINGBEE.LKPSTYLES(
    STYLEID ASCII,
    NAME ASCII,
    IMAGE ASCII,
    SEQUENCE INT,
    ACTIVE BOOLEAN,
    PRIMARY KEY (STYLEID,SEQUENCE)
)WITH CLUSTERING ORDER BY (SEQUENCE DESC);
like image 788
Girish Avatar asked Nov 22 '14 05:11

Girish


People also ask

Can we update primary key in Cassandra?

In Cassandra, primary keys are immutable so an update that changes a primary key must be treated as a delete and an insert.

How does Cassandra Query work?

Cassandra distributes the partition accross the nodes using the selected partitioner. As only the ByteOrderedPartitioner keeps an ordered distribution of data Cassandra does not support >, >=, <= and < operator directly on the partition key.


2 Answers

While having your complete query would help, I can tell from the error message that you are trying to UPDATE a row's PRIMARY KEY. From the DataStax documentation on the UPDATE command:

The UPDATE SET operation is not valid on a primary key field.

This is why you are getting this particular error message. If you have inserted a row containing a part of the primary key that you need to update, you will have to remove that row and re-insert it.

like image 63
Aaron Avatar answered Sep 23 '22 15:09

Aaron


Cassandra don't allow you to update primary key. You can not do something like below because SEQUENCE is part of primary key.

UPDATE STYLINGBEE.LKPSTYLES SET SEQUENCE = 1 WHERE STYLEID = 1000;

like image 23
user2584951 Avatar answered Sep 20 '22 15:09

user2584951