scala.ScalaReflectionException:< none>不是一个名词 [英] scala.ScalaReflectionException: <none> is not a term

查看:287
本文介绍了scala.ScalaReflectionException:< none>不是一个名词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在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:&lt; none&gt;不是一个名词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆