File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
src/main/java/com/sparkTutorial/sparkSql Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change 22
33import org .apache .log4j .Level ;
44import org .apache .log4j .Logger ;
5+ import org .apache .spark .api .java .function .FilterFunction ;
56import org .apache .spark .sql .*;
67
78import static org .apache .spark .sql .functions .avg ;
@@ -38,19 +39,21 @@ public static void main(String[] args) throws Exception {
3839 typedDataset .show (20 );
3940
4041 System .out .println ("=== Print the responses from Afghanistan ===" );
41- typedDataset .filter (response -> response .getCountry ().equals ("Afghanistan" )).show ();
42+ typedDataset .filter (( FilterFunction < Response >) response -> response .getCountry ().equals ("Afghanistan" )).show ();
4243
4344 System .out .println ("=== Print the count of occupations ===" );
4445 typedDataset .groupBy (typedDataset .col ("occupation" )).count ().show ();
4546
4647 System .out .println ("=== Print responses with average mid age less than 20 ===" );
47- typedDataset .filter (response -> response .getAgeMidPoint () !=null && response .getAgeMidPoint () < 20 ).show ();
48+ typedDataset .filter ((FilterFunction <Response >)response -> response .getAgeMidPoint () !=null &&
49+ response .getAgeMidPoint () < 20 )
50+ .show ();
4851
4952 System .out .println ("=== Print the result by salary middle point in descending order ===" );
5053 typedDataset .orderBy (typedDataset .col (SALARY_MIDPOINT ).desc ()).show ();
5154
5255 System .out .println ("=== Group by country and aggregate by average salary middle point and max age middle point ===" );
53- typedDataset .filter (response -> response .getSalaryMidPoint () != null )
56+ typedDataset .filter (( FilterFunction < Response >) response -> response .getSalaryMidPoint () != null )
5457 .groupBy ("country" )
5558 .agg (avg (SALARY_MIDPOINT ), max (AGE_MIDPOINT ))
5659 .show ();
You can’t perform that action at this time.
0 commit comments