Skip to content

Commit 9ef522f

Browse files
author
James Lee
committed
update TypedDataset
1 parent 69ee9eb commit 9ef522f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/main/java/com/sparkTutorial/sparkSql/TypedDataset.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import org.apache.log4j.Level;
44
import org.apache.log4j.Logger;
55
import org.apache.spark.api.java.function.FilterFunction;
6+
import org.apache.spark.api.java.function.MapFunction;
67
import org.apache.spark.sql.*;
78

89
import static org.apache.spark.sql.functions.avg;
@@ -59,8 +60,9 @@ public static void main(String[] args) throws Exception {
5960
.show();
6061

6162
System.out.println("=== Group by salary bucket ===");
62-
typedDataset.map(response -> response.getSalaryMidPoint() == null ?
63-
null : Math.round(response.getSalaryMidPoint()/20000) * 20000, Encoders.INT())
63+
typedDataset.map((MapFunction<Response, Integer>) response -> response.getSalaryMidPoint() == null ?
64+
null :
65+
Math.round(response.getSalaryMidPoint()/20000) * 20000, Encoders.INT())
6466
.withColumnRenamed("value", SALARY_MIDPOINT_BUCKET)
6567
.groupBy(SALARY_MIDPOINT_BUCKET)
6668
.count()

0 commit comments

Comments
 (0)