|
2 | 2 |
|
3 | 3 | importorg.apache.log4j.Level;
|
4 | 4 | importorg.apache.log4j.Logger;
|
5 |
| -importorg.apache.spark.sql.DataFrameReader; |
6 |
| -importorg.apache.spark.sql.Dataset; |
7 |
| -importorg.apache.spark.sql.Row; |
8 |
| -importorg.apache.spark.sql.SparkSession; |
| 5 | +importorg.apache.spark.sql.*; |
9 | 6 |
|
10 | 7 | importstaticorg.apache.spark.sql.functions.avg;
|
11 | 8 | importstaticorg.apache.spark.sql.functions.col;
|
@@ -39,8 +36,8 @@ public static void main(String[] args) throws Exception {
|
39 | 36 | responses.filter(col("country").equalTo("Afghanistan")).show();
|
40 | 37 |
|
41 | 38 | System.out.println("=== Print the count of occupations ===");
|
42 |
| -responses.groupBy(col("occupation")).count().show(); |
43 |
| - |
| 39 | +RelationalGroupedDatasetgroupedDataset =responses.groupBy(col("occupation")); |
| 40 | +groupedDataset.count().show(); |
44 | 41 |
|
45 | 42 | System.out.println("=== Cast the salary mid point and age mid point to integer ===");
|
46 | 43 | Dataset<Row>castedResponse =responses.withColumn(SALARY_MIDPOINT,col(SALARY_MIDPOINT).cast("integer"))
|
|