[英]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.