【发布时间】:2020-06-16 03:44:19
【问题描述】:
我编写了以下代码,旨在使用案例类将数据框转换为数据集
def toDs[T](df: DataFrame): Dataset[T] = {
df.as[T]
}
然后case class DATA( name:String, age:Double, location:String)
我得到:
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.
[error] df.as[T]
知道如何解决这个问题
【问题讨论】:
-
为什么不
df.as[DATA]? -
我想让它参数化
-
您是否按照错误导入了
spark.implicits._?
标签: scala apache-spark dataset