将rdd保存到cassandra表时出错:NoSuchElementException:找不到键

时间:2018-03-26 14:55:26

标签: apache-spark cassandra apache-kafka spark-streaming spark-cassandra-connector

我正在尝试将rdd保存到cassandra表但是收到此错误。有些人可以告诉我我做错了什么。

Exception in thread "main" java.util.NoSuchElementException: key not found: date

18/03/26 05:35:39 INFO CassandraConnector: Disconnected from Cassandra cluster: Test Cluster

我的火花代码是

val lines = KafkaUtils.createStream(ssc, "localhost:2181", "spark-streaming-consumer-group", Map("hello" -> 5))
val cass=sparkConf.set("spark.cassandra.connection.host","127.0.1.1")
val data=lines.map(_._2)
  val ndata=data.map(Tuple1())
ndata.saveToCassandra("mydata","stations")

数据rdd就像

{"id":"04bBGJpwUh","date":"2018-03-26 05:28:25","temp":37,"press":16}
{"id":"pi4Axn3iOd","date":"2018-03-26 05:28:27","temp":49,"press":17}

Cassandra表是

CREATE TABLE mydata.stations(id text primary key,date text,temp int,press int);

0 个答案:

没有答案