cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maxim Parkachov <>
Subject How to query TTL on collections ?
Date Wed, 19 Jun 2019 07:20:53 GMT
Hi everyone,

I'm struggling to understand how can I query TTL on the row in collection (
Cassandra 3.11.4 ).
Here is my schema:

  csn bigint,
  name text

CREATE TABLE products (
  product_id bigint PRIMARY KEY,
  items map<bigint, frozen<item>>

And I'm creating records with TTL like this:

UPDATE products USING TTL 10 SET items = items + {10: {csn: 100, name:
'item100'}} WHERE product_id = 1;
UPDATE products USING TTL 20 SET items = items + {20: {csn: 200, name:
'item200'}} WHERE product_id = 1;

As expected first records disappears after 10 seconds and the second after
20. But if I already have data in the table I could not figure out how to
query TTL on the item value:

SELECT TTL(items) FROM products WHERE product_id=1;
InvalidRequest: Error from server: code=2200 [Invalid query]
message="Cannot use selection function ttl on collections"

SELECT TTL(items[10]) FROM products WHERE product_id=1;
SyntaxException: line 1:16 mismatched input '[' expecting ')' (SELECT

Any tips, hints, tricks are highly appreciated,

View raw message