rdd.saveToCassandra(
keyspaceName = config.cassandraKeyspace,
tableName = config.cassandraTable,
columns = SomeColumns(
"session_id",
"list_col" append, // append doesn't allow the TTL to be set...? Remove it and you get a TTL
"timestamp"
),
writeConf = WriteConf(ttl = TTLOption.constant(100))
)
In that current configuration, running a streaming job and checking the destination table,
select ttl(timestamp) from keyspace.table;
no ttl is being set (all nulls), if you remove the append and allow it to just overwrite you now get TTLs on the column. I'm not sure if it's completely ignoring the entire writeConf as I do have other settings in my spark conf I was passing via fromSparkConf when I noticed this.
val spark = SparkSession.builder()
.appName(appName)
.config("spark.serializer", "org.apache.spark.serializer.KryoSerializer")
.config("spark.cassandra.connection.keep_alive_ms", "60000")
.config("spark.cassandra.connection.host", config.cassandraHosts)
.config("spark.cassandra.auth.username", config.cassandraUser)
.config("spark.cassandra.auth.password", config.cassandraPassword)
.config("spark.cassandra.output.batch.size.bytes", "8000")
.config("spark.cassandra.output.concurrent.writes", "300")
.config("spark.cassandra.output.ttl", config.cassandraRowTTL)
.config("spark.metrics.namespace", appName)
.config("spark.streaming.backpressure.enabled", "false")
.getOrCreate()
// use the write settings from spark conf
val cassWriteConf = WriteConf.fromSparkConf(spark.sparkContext.getConf)
// Was then passing this to writeConf
Has anyone else noticed this? Is this expected because of the collection type, or something?
I ported my dataframe api saves to use saveToCassandra so that I could use this append functionality :)
As a workaround I can use a default ttl on the table level, but would be nice to set it per row if needed.
Thanks!
--
You received this message because you are subscribed to the Google Groups "DataStax Spark Connector for Apache Cassandra" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spark-connector-...@lists.datastax.com.
> you can see current version of TableWrite.scala in this link: https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_datastax_spark-2Dcassandra-2Dconnector_blob_v2.0.5_spark-2Dcassandra-2Dconnector_src_main_scala_com_datastax_spark_connector_writer_TableWriter.scala&d=DwIFaQ&c=adz96Xi0w1RHqtPMowiL2g&r=mPa4DVY9Tr2PgOr6pcYcDSTS5OGYiRXFr0-h3mIgaEU&m=XxjRiEvrnUwVxAwdYs-v2pGbkw-iIAPkWKOVL7vVZBQ&s=JIr0eUk6ekN1sVd_hg83fPR84rIr2Iu5eBDlaKLaLEU&e=