3

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

Shai
  • 119
  • 1
  • 8
  • 1
    For newer versions this is the documentation: https://github.com/datastax/spark-cassandra-connector/blob/master/doc/5_saving.md#specifying-ttl-and-writetime – Oosterman May 29 '17 at 17:20

2 Answers2

4

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

Andy Tolbert
  • 11,418
  • 1
  • 30
  • 45
1

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

Note: Value should be in second

Abhishek Mishra
  • 611
  • 4
  • 11