[Spark SQL]: Dataset<Row> can not map into Dataset<Integer> in java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[Spark SQL]: Dataset<Row> can not map into Dataset<Integer> in java

Himasha de Silva
Hi,

 I'm trying to map a Dataset<Row> that read from csv files into a Dataset<Integer>. 
But it gives some errors. Can anyone please help me to figure it out?

Dataset<Row> t_en_data = session.read().option("header","true")
.option("inferSchema","true")
.csv("J:\\csv_path\\T_EN");

Dataset<Integer> mappedDataset = t_en_data
.map((MapFunction<Row, Integer>) row ->row.<Integer>getAs("Duration"), Encoders.INT());
mappedDataset.show(false);


Thanks
--

Himasha De Silva