Vipul Fadte
Vipul Fadte

Reputation: 63

Cassandra update multiple rows based on condition

I want to update multiple rows in Cassandra if they satisfy my condition with same value(changing flag to false) and my condition field is part of my composite key. But I cannot use whole composite key.

Upvotes: 3

Views: 5809

Answers (1)

Aaron
Aaron

Reputation: 57808

Unfortunately, this is not possible with Cassandra. UPDATEs and INSERTs are all considered write operations. And write operations require a complete PRIMARY KEY.

Consider this example where I have a partition key of username and a clustering key of transaction_time: PRIMARY KEY (username,transaction_time). If I just try to UPDATE based on username, this fails.

cassdba@cqlsh:stackoverflow> UPDATE rest_transactions_by_user
       SET http_result = 200 WHERE username='Aaron';
InvalidRequest: Error from server: code=2200 [Invalid query] 
       message="Some clustering keys are missing: transaction_time"

Upvotes: 5

Related Questions