如何更新Apache Spark DataFrame中的行/列值?

Ume*_*cha 7 apache-spark apache-spark-sql spark-dataframe

嗨,我有一个有序的Spark DataFrame,我想在使用下面的代码迭代它时改变几行,但似乎没有任何方法来更新Row对象

orderedDataFrame.foreach(new Function1<Row,BoxedUnit>(){

@Override
public BoxedUnit apply(Row v1) {
//how to I change Row here 
//I want to change column no 2 using v1.get(2)
//also what is BoxedUnit how do I use it
return null;
}
});
Run Code Online (Sandbox Code Playgroud)

上面的代码也提供编译错误说"myclassname is not abstract and it does not override abstract method apply$mcVj$sp(long) in scala Function 1" 请指导.我是Spark的新手.我正在使用1.4.0版本.

Pio*_*ski 9

试试这个:

 final DataFrame withoutCurrency = sqlContext.createDataFrame(somedf.javaRDD().map(row -> {
            return RowFactory.create(row.get(0), row.get(1), someMethod(row.get(2)));
        }), somedf.schema());
Run Code Online (Sandbox Code Playgroud)