简体   繁体   English

java.util.NoSuchElementException:Cassandra Spark中的表demo.usertable中找不到列ID

[英]java.util.NoSuchElementException: Column not found ID in table demo.usertable in Cassandra Spark

I am try to write RDD[CassandraRow] into existing Cassandra Table using Spark-cassandra-Connector. 我尝试使用Spark-cassandra-Connector将RDD [CassandraRow]写入现有的Cassandra表。 Here is my piece of code 这是我的一段代码

val conf = new SparkConf().setAppName(getClass.getSimpleName)
            .setMaster("local[*]")
            .set("spark.cassandra.connection.host", host)
        val sc = new SparkContext("local[*]", keySpace, conf)
val rdd = sc.textFile("hdfs://hdfs-host:8020/Users.csv")
val columns = Array("ID", "FirstName", "LastName", "Email", "Country")
val types = Array("int", "string", "string", "string", "string")
val crdd=rdd.map(p => {
            var tokens = p.split(",")
            new CassandraRow(columns,tokens)
        })
val targetedColumns = SomeColumns.seqToSomeColumns(columns)
crdd.saveToCassandra(keySpace, tableName, targetedColumns,  WriteConf.fromSparkConf(conf))

When I run this code I get following exception 当我运行此代码时,我得到以下异常

Exception in thread "main" java.util.NoSuchElementException: Column not found ID in table demo.usertable

here is actual schema of table 这是表的实际架构

CREATE TABLE usertable (
  id int,
  country text,
  email text,
  firstname text,
  lastname text,
  PRIMARY KEY ((id))
)

Any suggestion? 有什么建议吗? Thanks 谢谢

Keyspace, table and column names are case sensitive in Cassandra. Keyspace,表格和列名称在Cassandra中区分大小写。 Have you tried adjusting your code to use the same case as the table definition? 您是否尝试过调整代码以使用与表定义相同的大小写? (For example use 'id' instead of 'ID'). (例如,使用'id'而不是'ID')。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 spark scala throws java.util.NoSuchElementException:key not found:0 exception - spark scala throws java.util.NoSuchElementException: key not found: 0 exception Spark抛出java.util.NoSuchElementException:找不到键:67 - Spark throws java.util.NoSuchElementException: key not found: 67 Spark Scala使用广播变量抛出“ java.util.NoSuchElementException:找不到密钥” - Spark Scala throws “java.util.NoSuchElementException: key not found” with Broadcast variable Scala Spark SQL:java.util.NoSuchElementException:找不到键:LINE_TYPE - Scala Spark SQL : java.util.NoSuchElementException: key not found: LINE_TYPE java.util.NoSuchElementException:spark.executor.cores - java.util.NoSuchElementException: spark.executor.cores Spark 2.0.1写入错误:原因:java.util.NoSuchElementException - Spark 2.0.1 write Error: Caused by: java.util.NoSuchElementException Scala Map java.util.NoSuchElementException:找不到键优雅 - scala map java.util.NoSuchElementException: key not found elegant Scala-获取java.util.NoSuchElementException - scala - getting java.util.NoSuchElementException Scala HashMap:java.util.NoSuchElementException - Scala HashMap: java.util.NoSuchElementException Dataproc 集群中的 Scala Spark 作业返回 java.util.NoSuchElementException: None.get - Scala Spark Job in Dataproc cluster returns java.util.NoSuchElementException: None.get
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM