cql - setting TTL using timestamp field of record during insertion in cassandra -


i want set ttl 30 days time field of table record(id,name,time) during insertion. creating user defined function(udf) bigint fun(rtime,ctime) as

create function fun(rtime timestamp,ctime timestamp) called on null input   returns bigint language java 'return 2592000-((ctime.totime() -rtime.totime())/1000);'; 

here,function fun calculating time in seconds data should live. 2592000 time in seconds 30 days.

now trying use above function setting ttl

insert record(id,name,time) values (123,'data123','2016-08-08 06:06:00')  using ttl fun('2016-08-08 06:06:00',totimestamp(now())); 

getting error as

syntax exception: errormessage code=2000 ........

is there other way set ttl based on record time field. problem above approach?

function call not supported in using clause. in case, client have calculate appropriate ttl , pass in query second.


Comments