Skip to content

Commit

Permalink
fix SQL bucket group, orderby op code
Browse files Browse the repository at this point in the history
  • Loading branch information
yennanliu committed Dec 27, 2018
1 parent db70ded commit aef72cd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions spark_/spark_SQL_analysis.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ public static void main(String[] args) throws Exception {


Dataset<Row> responseWithSalaryBucket = castedResponse.withColumn(
PICKUP_LATITUDE_BUCKET, col(PICKUP_LATITUDE).divide(2).cast("integer").multiply(3));
PICKUP_LATITUDE_BUCKET, col(PICKUP_LATITUDE).divide(0.2).cast("integer").multiply(0.2));

System.out.println("=== With salary bucket column ===");
System.out.println("=== With PICKUP_LATITUDE_BUCKET column ===");
responseWithSalaryBucket.select(col(PICKUP_LATITUDE), col(PICKUP_LATITUDE_BUCKET)).show();

//System.out.println("=== Group by salary bucket ===");
//responseWithSalaryBucket.groupBy(SALARY_MIDPOINT_BUCKET).count().orderBy(col(SALARY_MIDPOINT_BUCKET)).show();
System.out.println("=== Group by PICKUP_LATITUDE_BUCKET ===");
responseWithSalaryBucket.groupBy(PICKUP_LATITUDE_BUCKET).count().orderBy(col(PICKUP_LATITUDE_BUCKET)).show();

session.stop();
}
Expand Down

0 comments on commit aef72cd

Please sign in to comment.