I'm trying to read a Cassandra table (mykeyspace.mytable
) from inside a Spark 2.1 job (using Scala 2.11):
val myDataset = sqlContext
.read
.format("org.apache.spark.sql.cassandra")
.options(Map("table" -> "mytable", "keyspace" -> "mykeyspace"))
.load()
myDataset.show()
println(s"Ping and the count is: ${myDataset.count}")
myDataset.foreach(t => println("Weee"))
println("Pong")
When this runs, the console output is:
+--------------+-----------+
| username|modified_at|
+--------------+-----------+
|sluggoo-flibby| null|
+--------------+-----------+
Ping and the count is: 1
Pong
So there's clearl a single record in this table...but why is my foreach
loop "not working?" Why don't I see my "Weee" output?