Skip to content

Commit

Permalink
Merge pull request #31 from neeleshkumar-mannur/patch-4
Browse files Browse the repository at this point in the history
Added Java code for Chapter 4
  • Loading branch information
bllchmbrs authored Oct 10, 2018
2 parents 4d837f8 + 065fab6 commit 38e8814
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions code/Structured_APIs_Chapter_4_Structured_API_Overview.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
This Java code was contributed by @neeleshkumar-mannur

import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
import org.apache.spark.sql.SparkSession;

public class Structured_APIs_Chapter_4_Structured_API_Overview {
public static void main(String[] args) {
SparkSession spark = SparkSession
.builder()
.master("local[*]")
.appName("Chapter4StructuredAPIOverview")
.getOrCreate();

Dataset<Row> df = spark.range(500).toDF("number");
df.select(df.col("number").plus(10)).show();

Object [] dataObjects = (Object[])spark.range(2).toDF().collect();
for(Object object: dataObjects) {
System.out.println(object.toString());
}

}
}

0 comments on commit 38e8814

Please sign in to comment.