spark encoder错误,需要import spark.implicits._

Error:(33, 64) Unable to find encoder for type stored in a Dataset.  Primitive types (Int, String, etc) and Product types (case classes) are supported by importing spark.implicits._  Support for serializing other types will be added in future releases.
    val values = sources.selectExpr("cast(value as string)").as[String]

import spark.implicits._//注意要放在全局的位置,尤其是方法调用  process_data(values)此方法内部使用到df.map方法,如果在main方法里引入上面的一句,则还是会报错!
val values = sources.selectExpr("cast(value as string)").as[String]

猜你喜欢

转载自blog.csdn.net/lsx6766/article/details/88421772