Apache Spark Component Guide
Also available as:
PDF
loading table of contents...

Using Spark SQL

Using SQLContext, Apache Spark SQL can read data directly from the file system. This is useful when the data you are trying to analyze does not reside in Apache Hive (for example, JSON files stored in HDFS).

Using HiveContext, Spark SQL can also read data by interacting with the Hive MetaStore. If you already use Hive, you should use HiveContext; it supports all Hive data formats and user-defined functions (UDFs), and it enables you to have full access to the HiveQL parser. HiveContext extends SQLContext, so HiveContext supports all SQLContext functionality.

There are two ways to interact with Spark SQL:

The following diagram illustrates the access process, depending on whether you are using the Spark shell or business intelligence (BI) application:

This subsection describes how to access Spark SQL through the Spark shell, and through JDBC and ODBC. The third section describes how to form JDBC connection strings for Spark SQL, and the final section shows how to call Hive user-defined functions from Spark shell applications.