Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb98b1de

Browse files
author
James Lee
committed
improve StackOverFlowSurvey
1 parentce367cf commitb98b1de

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

‎src/main/java/com/sparkTutorial/sparkSql/StackOverFlowSurvey.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22

33
importorg.apache.log4j.Level;
44
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.*;
96

107
importstaticorg.apache.spark.sql.functions.avg;
118
importstaticorg.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+
RelationalGroupedDatasetgroupedDataset =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"))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp