Shai
Shai

Reputation: 119

Spark saving to Cassandra with TTL

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

Upvotes: 3

Views: 2494

Answers (2)

Abhishek Mishra
Abhishek Mishra

Reputation: 639

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

Note: Value should be in second

Upvotes: 1

Andy Tolbert
Andy Tolbert

Reputation: 11638

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().

Upvotes: 4

Related Questions