Developing Apache Spark Applications
Also available as:
PDF

Access Spark SQL through the Spark shell

Use the following steps to acess Spark SQL using the Spark shell.

The following sample command launches the Spark shell on a YARN cluster:

./bin/spark-shell --num-executors 1 --executor-memory 512m --master yarn-client

To read data directly from the file system, construct a SQLContext. For an example that uses SQLContext and the Spark DataFrame API to access a JSON file, see "Using the Spark DataFrame API" in this guide.

To read data by interacting with the Hive Metastore, construct a HiveContext instance (HiveContext extends SQLContext). For an example of the use of HiveContext (instantiated as val sqlContext), see "Accessing ORC Files from Spark" in this guide.