【发布时间】:2017-10-30 01:56:05
【问题描述】:
我怎样才能让这个方法编译。奇怪的是,sparksimplicit 已经被导入了。
def loadDsFromHive[T <: Product](tableName: String, spark: SparkSession): Dataset[T] = {
import spark.implicits._
spark.sql(s"SELECT * FROM $tableName").as[T]
}
这是错误:
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] spark.sql(s"SELECT * FROM $tableName").as[T]
【问题讨论】:
-
Product中除了原语还有哪些其他类型?
-
我想使用一个案例类并且只使用原语。但是上面的这个 sn-p 字面上不会编译。
标签: scala apache-spark generics apache-spark-dataset apache-spark-encoders