【Spark】error: value foreach is not a member of Object
程序员文章站
2022-07-13 22:18:46
...
spark项目,scala 从2.11 升级到2.12 编译报错:error: value foreach is not a member of Object
代码:
df.foreachPartition{iter=>
iter.foreach{row =>
}
}
升级2.12之后,Dataset的foreachPartition 里面不能处理 Row
的Iterator;具体原因不太清楚。
解决方法
1、把Dataset转成RDD,在处理;
df.rdd.foreachPartition{iter=>
iter.foreach{row =>
}
}
2、就是使用 foreach 替代foreachPartition
推荐阅读
-
【Spark】error: value foreach is not a member of Object
-
error: object MultivariateNormalDistribution is not a member of package
-
解决Field error in object ‘tbPet‘ on field ‘birthday‘: rejected value [2020-07-30]; codes [typeMismatch.
-
[VUE ERROR] Invalid default value for prop "slides": Props with type Object/Array must use a factory function to return the default value
-
求大神纠错,多谢!Fatal error: Call to a member function query() on a non-object
-
Fatal error: Call to a member function fetch_array() on a non-object in 62 line
-
Fatal error: Call to a member function fetch_array() on a non-object in 62 line
-
【】Fatal error: Call to a member function * on a non-object
-
Fatal error: Call to a member function fetch_array() on a non-object in 62 line,该如何处理
-
Error:cannot call member function without object