scala.ScalaReflectionException: <none> is not a term

你说的曾经没有我的故事 提交于 2019-12-05 02:35:41
def processFunction(src: String): (Any, Any) = {
  src match {
   case "a" => (A("a", 123112, "b"), A("b", 142342, "c"))
   case "b" => (B("d", 12312, "e", "f"), B("g", 12312, "h", "i"))
  }
}

Something like that may work. I haven't played around too much with saving objects in cassandra though. Nor using any with cassandra. However, the above solution without the case classes and anys is how I solved such an issue recently. For instance, the below would work.

def processFunction(src: String): (String, Int, String) = {
   src match {
     case "a" => ("a", 123112, "b")
     case "b" => ("d", 12312, "e")
   }
}

However, that is not exactly what you want. So yeah, take it for what you will.

game_changer

I faced this issue and applying case class on this will help you resolve this issue.

Below is the example.

 case class test_row(col1: String,
                col2: String,
                col3: String)

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!