Skip to content

Bonus Chapter B07: SQL on Spark

Chapter notes: chapB07/sql

Sample input: data/chapB07/people.txt

Run the commands from the repository folder after building the jar (Running the programs).

Spark (Java)

chapB07.sql.SparkSQLExample

Source: SparkSQLExample.java

scripts/run_spark.sh org.dataalgorithms.chapB07.sql.SparkSQLExample data/chapB07/people.txt
  • Writes to people.parquet/ in the current directory; delete it first if it exists: rm -r people.parquet
  • Reads examples/src/main/resources/people.json: copy data/chapB07/people.json there first.

chapB07.sql.SparkSQLExampleWithLambda

Source: SparkSQLExampleWithLambda.java

scripts/run_spark.sh org.dataalgorithms.chapB07.sql.SparkSQLExampleWithLambda data/chapB07/people.txt
  • Writes to people.parquet/ in the current directory; delete it first if it exists: rm -r people.parquet
  • Reads examples/src/main/resources/people.json: copy data/chapB07/people.json there first.