尝试从 s3 读取数据集时出现异常。公司案例类包含带有员工案例类的集合。
Exception in thread "main" java.lang.UnsupportedOperationException: No Encoder found for Set[com.model.company.common.Employee]
- field (class: "scala.collection.immutable.Set", name: "employees")
- field (class: "com.model.company.Company", name: "company")
我试过kryo:
implicit def myDataEncoder[T]: Encoder[Set[Employee]] = Encoders.kryo[scala.collection.immutable.Set[Employee]
但它也不起作用。您知道如何将 scala 集合转换为数据集吗?
代码:
val sqlContext = sparkSession.sqlContext import sqlContext.implicits._ val records = sparkSession.read.json(s"s3a://${config.input.fullPath}").as[Company]