获取异常 java.util.NoSuchElementException: 找不到键: 在 spark-cassandra-connector 中'text'



我想将数据从spark RDD保存到cassandra表。我使用的是来自https://github.com/datastax/spark-cassandra-connector

根据文档保存的代码

rddJavaFunctions.writerBuilder("populartweets", "stream_tag_count",
                CassandraJavaUtil.mapToRow(Tag.class)).withColumnSelector(CassandraJavaUtil.someColumns("tag","count"))
                .saveToCassandra();

在这个操作之后,我得到错误

    New Cassandra host /127.0.0.1:9042 added
15/12/16 10:18:06 INFO CassandraConnector: Connected to Cassandra cluster: Test Cluster
Exception in thread "main" java.util.NoSuchElementException: key not found: 'text'
    at scala.collection.MapLike$class.default(MapLike.scala:228)
    at scala.collection.AbstractMap.default(Map.scala:58)
    at scala.collection.MapLike$class.apply(MapLike.scala:141)
    at scala.collection.AbstractMap.apply(Map.scala:58)
    at com.datastax.spark.connector.types.ColumnType$.fromDriverType(ColumnType.scala:81)
    at com.datastax.spark.connector.cql.ColumnDef$.apply(Schema.scala:117)
    at com.datastax.spark.connector.cql.Schema$$anonfun$com$datastax$spark$connector$cql$Schema$$fetchPartitionKey$1.apply(Schema.scala:199)
    at com.datastax.spark.connector.cql.Schema$$anonfun$com$datastax$spark$connector$cql$Schema$$fetchPartitionKey$1.apply(Schema.scala:198)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
    at scala.collection.Iterator$class.foreach(Iterator.scala:727)
    at scala.collection.AbstractIterator.foreach(Iterator.scala:1157)
    at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
    at scala.collection.AbstractIterable.foreach(Iterable.scala:54)

我使用的是spark 1.5.2

Cassandra 3.x已解决此问题。请使用火花连接器1.5.0-RC1(最新版本)。

相关内容

  • 没有找到相关文章

最新更新