scala.ScalaReflectionException:< none>不是一个名词 [英] scala.ScalaReflectionException: <none> is not a term
问题描述
我在Spark中有以下代码段:
I have the following piece of code in Spark:
rdd
.map(processFunction(_))
.saveToCassandra("keyspace", "tableName")
哪里
def processFunction(src: String): Seq[Any] =
src match {
case "a" => List(A("a", 123112, "b"), A("b", 142342, "c"))
case "b" => List(B("d", 12312, "e", "f"), B("g", 12312, "h", "i"))
}
位置:
case class A(entity: String, time: Long, value: String)
case class B(entity: String, time: Long, value1: String, value2: String)
saveToCassandra
期望对象的集合,并使用Seq[Any]
作为返回类型,同时包含Seq[A]
和Seq[B]
,中断saveToCassandra
除外-scala.ScalaReflectionException: <none>
不是术语.这种行为可能是什么原因?
saveToCassandra
expects a collection of objects and using Seq[Any]
as the return type to contain both Seq[A]
and Seq[B]
breaks saveToCassandra
with the exception - scala.ScalaReflectionException: <none>
is not a term. What could be the reason for this behaviour?
推荐答案
我遇到了此问题,为此应用案例类将帮助您解决此问题.
I faced this issue and applying case class on this will help you resolve this issue.
下面是示例.
case class test_row(col1: String,
col2: String,
col3: String)
然后将此案例类应用于df/rdd.
And apply this case class on a df/rdd.
df.map { x => test_row.apply(x.get(0).asInstanceOf[String], x.get(1).asInstanceOf[String],x.get(2).asInstanceOf[String])
}.rdd.saveToCassandra
此已解决的无"不是术语问题.
This resolved 'none' is not a term issue.
这篇关于scala.ScalaReflectionException:< none>不是一个名词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!