James Kristen
James Kristen

Reputation: 75

How to set TTL to columns that are mentioned in where clause when using UPDATE

I understand that Cassandra updates the ttl to all the columns that I insert when I am USING TTL. But how can I update the ttl for rest of the columns that are mentioned in where clause.

Here is an example

   UPDATE NerdMovies (movie, director, main_actor, year)
   VALUES ('Serenity', 'Joss Whedon', 'Nathan Fillion', 2005) where
   language = 'English' and country = 'US'
   USING TTL 86400;

This only updates the columns movie, director, main_actor, year.I want to update the TTL for columns language and country too (which are primary keys by the way). How can I achieve that?

Upvotes: 0

Views: 60

Answers (1)

Valerie Parham-Thompson
Valerie Parham-Thompson

Reputation: 1566

You can't set TTL on primary keys. You can vote for a feature to do this at https://issues.apache.org/jira/browse/CASSANDRA-9312 (but may not apply to your use case, if all columns are not PK).

You could read out the values and then upsert them with the TTL, like:

   INSERT INTO NerdMovies (movie, director, main_actor, year, language, country)
   VALUES ('Serenity', 'Joss Whedon', 'Nathan Fillion', '2005', 'English', 'US')
   USING TTL 86400;

Upvotes: 1

Related Questions