Spark writing to Cassandra with varying TTL
Spark writing to Cassandra with varying TTL In Java Spark, I have a dataframe that has a 'bucket_timestamp' column, which represents the time of the bucket that the row belongs to. I want to write the dataframe to a Cassandra DB. The data must be written to the DB with TTL. The TTL should be depended on the bucket timestamp - where each row's TTL should be calculated as ROW_TTL = CONST_TTL - (CurrentTime - bucket_timestamp) , where CONST_TTL is a constant TTL that I configured. ROW_TTL = CONST_TTL - (CurrentTime - bucket_timestamp) CONST_TTL Currently I am writing to Cassandra with spark using a constant TTL, with the following code: df.write().format("org.apache.spark.sql.cassandra") .options(new HashMap<String, String>() { { put("keyspace", "key_space_name"); put("table, "table_name"); put("spark.cassandra.output.ttl, Long.toStri...
