0
votes

I am pretty new to spark-cassandra.

I am going through the documentation of spark-casssandra connector to figure out how to update cassandra collections. This link(https://github.com/datastax/spark-cassandra-connector/blob/master/doc/5_saving.md) has the following code to update collections:

val listElements = sc.parallelize(Seq(
  (1,Vector("One")),
  (1,Vector("Two")),
  (1,Vector("Three"))))

val prependElements = sc.parallelize(Seq(
  (1,Vector("PrependOne")),
  (1,Vector("PrependTwo")),
  (1,Vector("PrependThree"))))

listElements.saveToCassandra("ks", "collections_mod", SomeColumns("key", "lcol" append))
prependElements.saveToCassandra("ks", "collections_mod", SomeColumns("key", "lcol" prepend))

But when i try the above code in eclipse, i get an error near "lcol" append and "lcol" prepend

Error is : value append is not a member of String and value prepend is not a member of String

Am i missing anything here? How do i resolve this issue?

2

2 Answers

0
votes

Add import com.datastax.spark.connector._ to your code. This will bring an implicit conversion from String to ColumnName in your scope. ColumnName has the sought operations prepend and append available.

0
votes

I had the same problem. Upgrading sbt plugin to "com.datastax.spark" %% "spark-cassandra-connector" % "1.5.0-RC1" version and ran ./activator clean helped