8

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);
Aaron
  • 55,518
  • 11
  • 116
  • 132
Girish
  • 81
  • 1
  • 1
  • 2
  • strange, have you created key-space or not? if yes then use that key space and instead of STYLINGBEE.LKPSTYLES directly use your table-name, it's just and guess. not sure whether it will help or not. – Helping Hand.. Nov 22 '14 at 10:52
  • Although submitted by different users, this question asks about the same problem on the *same exact schema* as this question that I answered 30 minutes ago: http://stackoverflow.com/questions/27075596/how-to-update-clustering-key-in-cassandra-using-update-query/27078376#27078376 I can't mark either as a duplicate without an accepted, or upvoted answer. – Aaron Nov 22 '14 at 15:47

3 Answers3

10

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.

Aaron
  • 55,518
  • 11
  • 116
  • 132
3

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;

1

It looks like you are trying to update some row without STYLEID specified in your query (WHERE part). Could you please publish your CQL statement. I think this one link could help you: Why doesn't my Cassandra update work?

Community
  • 1
  • 1
Aleksey Kiselev
  • 331
  • 1
  • 7
  • 21