Saturday, August 27, 2016

Simple way to update rows in DataFrame

Lifehack for oldschool peoples, who prefer RDBMS-like approach.

  DataFrame reslt = sqlContext.createDataFrame(  
   srcDatafr.javaRDD().map(row -> {  
   return RowFactory.create(row.get(0), row.get(1), row.get(2), "You value", row.get(4) );  
   }), srcDatafr.schema());  
   reslt.printSchema();  
   reslt.show();   
   }     

Very beautiful solution, get it here.

No comments:

Post a Comment