File tree Expand file tree Collapse file tree 1 file changed +3
-6
lines changed
src/main/java/com/sparkTutorial/sparkSql Expand file tree Collapse file tree 1 file changed +3
-6
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 .sql .DataFrameReader ;
6- import org .apache .spark .sql .Dataset ;
7- import org .apache .spark .sql .Row ;
8- import org .apache .spark .sql .SparkSession ;
5+ import org .apache .spark .sql .*;
96
107import static org .apache .spark .sql .functions .avg ;
118import static org .apache .spark .sql .functions .col ;
@@ -39,8 +36,8 @@ public static void main(String[] args) throws Exception {
3936 responses .filter (col ("country" ).equalTo ("Afghanistan" )).show ();
4037
4138 System .out .println ("=== Print the count of occupations ===" );
42- responses .groupBy (col ("occupation" )). count (). show ( );
43-
39+ RelationalGroupedDataset groupedDataset = responses .groupBy (col ("occupation" ));
40+ groupedDataset . count (). show ();
4441
4542 System .out .println ("=== Cast the salary mid point and age mid point to integer ===" );
4643 Dataset <Row > castedResponse = responses .withColumn (SALARY_MIDPOINT , col (SALARY_MIDPOINT ).cast ("integer" ))
You can’t perform that action at this time.
0 commit comments