Search code examples
cassandracql

Cassandra - check TTL on rows for table with 2 primary keys


I have the following table:

 CREATE TABLE IF NOT EXISTS customers_by_store(
   customer_token uuid,
   store_id uuid,
   customer_name,
   customer_address
   nickname text,
   created timestamp,
   PRIMARY KEY((customer_token, store_id)));

I set a TTL on the rows when I insert them, but how can I be sure that it set the TTL?

I tried the following queries but I just get errors.

SELECT TTL(customer_token, store_id) from customers_by_store;

SELECT TTL(customer_token) from customers_by_store;

Example of an error - SyntaxException: line 1:32 mismatched input ',' expecting ')' (SELECT TTL (customer_token[,]...)

Please advise.


Solution

  • The TTL() function is similar to the WRITETIME() function, where it only operates on "payload" columns. So it won't work on key columns.

    SELECT TTL(customer_name) from customers_by_store;
    

    Querying the TTL for customer_name or another non-key column works.