Jake
Jake

Reputation: 4670

spark-cassandra-connector: add column on the fly

The following cqlsh command adds a column to an already existing cassandra table.

cqlsh:demodb> ALTER TABLE users ADD coupon_code varchar;

How would I do the same with the scala spark-cassandra-connector?

I am not seeing reference in the documents.

ALSO: Is there a scaladoc for com.datastax.spark.connector?

Upvotes: 0

Views: 560

Answers (1)

Alex Ott
Alex Ott

Reputation: 87299

You can use withSessionDo method of the CassandraConnector, like this:

import com.datastax.spark.connector.cql.CassandraConnector

CassandraConnector(conf).withSessionDo { session =>
   session.execute("ALTER TABLE users ADD coupon_code varchar;")
}

See more examples in documentation for Spark Cassandra connector...

Upvotes: 3

Related Questions