According to DataFrames API, definition is:
public void foreach(scala.Function1<Row,scala.runtime.BoxedUnit> f)
Applies a function f to all rows.
But when I am trying like
Dataframe df = sql.read()
.format("com.databricks.spark.csv")
.option("header","true")
.load("file:///home/hadoop/Desktop/examples.csv");
df.foreach(x->
{
System.out.println(x);
});
I am getting compile time error. any mistake?
foreachto print output. Third because there is a typo.DataFrameis with a big F ! I'm also voting to close the question for the matter.Function1<Row, BoxedUnit>does not seem to fit Java lambdas 2. if the parameter isdf.foreach(new AbstractFunction1<Row, BoxedUnit>() { @Override public BoxedUnit apply(Row arg0) { return null; } });, , it works just fine.