@@ -53,12 +53,17 @@ public static void main(String[] args) throws Exception {
53
53
castedResponse .orderBy (col (SALARY_MIDPOINT ).desc ()).show ();
54
54
55
55
System .out .println ("=== Group by country and aggregate by average salary middle point and max age middle point ===" );
56
- castedResponse .groupBy ("country" ).agg (avg (SALARY_MIDPOINT ),max (AGE_MIDPOINT )).show ();
56
+ RelationalGroupedDataset datasetGroupByCountry =castedResponse .groupBy ("country" );
57
+ datasetGroupByCountry .agg (avg (SALARY_MIDPOINT ),max (AGE_MIDPOINT )).show ();
58
+
57
59
58
- System .out .println ("=== Group by salary bucket ===" );
59
60
Dataset <Row >responseWithSalaryBucket =castedResponse .withColumn (SALARY_MIDPOINT_BUCKET ,col (SALARY_MIDPOINT ).divide (20000 ).cast ("integer" ).multiply (20000 ));
60
- responseWithSalaryBucket .groupBy (SALARY_MIDPOINT_BUCKET ).count ().orderBy (col (SALARY_MIDPOINT_BUCKET )).show ();
61
61
62
+ System .out .println ("=== With salary bucket column ===" );
63
+ responseWithSalaryBucket .select (col (SALARY_MIDPOINT ),col (SALARY_MIDPOINT_BUCKET )).show ();
64
+
65
+ System .out .println ("=== Group by salary bucket ===" );
66
+ responseWithSalaryBucket .groupBy (SALARY_MIDPOINT_BUCKET ).count ().orderBy (col (SALARY_MIDPOINT_BUCKET )).show ();
62
67
63
68
session .stop ();
64
69
}