【发布时间】:2019-12-11 19:33:39
【问题描述】:
import org.apache.spark.sql.functions._
case class oneClass(a : Int , b: String , c :string)
val doSomthing = udf ((t1 : Seq[String], str : String , values : t2 Seq[String])
=> {
val pos = t1.indexOf(str)
if (pos >= 0) oneClass(pos, str,t2(pos))
//if no control of pos possible return -1 ===> indexoutofboundsexception
//if control the udf return Any then when I use it ===> Exception
}
)
只有当 pos >= 0 并且一直返回 case class 时,我如何才能返回 case class ??
【问题讨论】:
标签: scala apache-spark user-defined-functions