3
votes

I am using Spark-Cassandra connector 1.1.0 with Cassandra 2.0.12.

I write RDDs to Cassandra via the saveToCassandra() Java API method.

Is there a way to set the TTL property of the persisted records with the connector?

Thanks,

Shai

2
For newer versions this is the documentation: github.com/datastax/spark-cassandra-connector/blob/master/doc/…Oosterman

2 Answers

4
votes

Unfortunately it doesn't seem like there is a way to do this (that I know of) with version 1.1.0 of the connector. There is a way in 1.2.0-alpha3 however.

saveToCassandra() is a wrapper over WriterBuilder which has a withTTL method. Instead of using saveToCassandra you could use writerBuilder(keyspace,table,rowWriter).withTTL(seconds).saveToCassandra().

1
votes

Yes, we can do. Just set spark config key "spark.cassandra.output.ttl" .while creating sparkConf Object.

Note: Value should be in second