我有两个数据集:Dataset[User]两者Dataset[Book]都是案例类User。Book我像这样加入他们:
val joinDS = ds1.join(ds2, "userid")
如果我尝试map覆盖 中的每个元素joinDS,编译器会抱怨缺少编码器:
not enough arguments for method map: (implicit evidence$46: org.apache.spark.sql.Encoder[Unit])org.apache.spark.sql.Dataset[Unit].
Unspecified value parameter evidence$46.
Unable to find encoder for type stored in a Dataset.
但是如果我使用foreach而不是map. 为什么也不foreach需要编码器?我已经从 spark 会话中导入了所有隐式,那么map当数据集是连接两个包含案例类的数据集的结果时,为什么还需要编码器?另外,我从那个连接中得到什么类型的数据集?是一个Dataset[Row],还是别的什么?