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);
In Cassandra, primary keys are immutable so an update that changes a primary key must be treated as a delete and an insert.
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.
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.
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With