问题描述
嗨,我正在尝试使用自定义案例类对 spark 数据集执行 groupBy 和一些聚合,但一直遇到错误。注意输出数据集我要和原始数据集的类型还是一样的。
case class ExampleRow(
a: String,b: String,c: Double,)
val origDataset: Dataset[ExampleRow] = ...
val newDataset: Dataset[ExampleRow] = origDataset
.groupByKey(r => r.a,r.b)
.agg(typed.avg[TimeUsageRow](_.other).name("c").as[Double])
我在运行时总是遇到这个错误:
type mismatch;
[error] found : org.apache.spark.sql.Dataset[((String,String),Double)]
[error] required: org.apache.spark.sql.Dataset[example.ExampleRow]
[error] .agg(
[error] ^
[error] one error found
有什么想法吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)