I want below mentioned data using Spark (2.2) dataset
Name Age Age+5
A 10 15
B 5 10
C 25 30
I tried using the following :
dataset.select(
dataset.col("Name"),
dataset.col("Age),
dataset.col( dataset.selectExpr("Age"+5).toString() )
);
This throws exception as Age
column not found.
selectExpr
has the definition :
public Dataset<Row> selectExpr(String... exprs)
It takes varargs String as it's parameter. So, you can just use :
dataset.selectExpr( "Name", "Age", "Age+5" )