Cassandra: delete of data with TTL, ROW with "null" value instead of being removed

Viewed 58

Small question regarding Cassandra please.

I have created a table as follow:

CREATE TABLE contract ( contractidentifier text, name text, telephone text, idnumber text, companyid text, company text, startdate timestamp, hiringdate timestamp, interviewdate timestamp,
                      PRIMARY KEY (contractidentifier, company, name)) WITH default_time_to_live = 2628000;

And the goal is very straightforward, the web application is just going to write some data about some short term contracts which only last for one month.

Since the employment is only a month long, what I would like to achieve from the table point of view is: "keep only the data for one month only. After that, it should be deleted".

With this requirement in mind, I simply used the TTL feature of Cassandra (see query, WITH default_time_to_live = 2628000).

Now, I come back after once month, expecting the data to be deleted. However, I can see the data is still there, with some null values:

       C102403845 | null |      null | SMITH | null |  null | null |  null | DELL |     null |    null | null |        null | null |  null

Questions:

What is the issue here please? Did I misunderstood the purpose of the TTL? (i.e. My understanding of the TTL is that the row will be entirely deleted after one month, not: the row is still after one month, with only some of the values being null)

If my understanding is correct, did I misconfigured something?

Finally, if the TTL is actually not the solution, what else could I use please?

Thank you

1 Answers

You would have inserted into table with updated ttl using the USING TTL construct. Otherwise it is not possible that table will have values after TTL time has passed. You can check remaining ttl for the columns for which the value is shown using following construct.

select ttl(column_name) from tablename where key= value;
Related