Spark - Sql
Table of Contents
1 - About
Spark SQL is a spark sql engine that supports:
- all existing Hive data formats,
- the hive syntax (user-defined functions - UDF),
- and the Hive metastore to get the metadata of the data stored in HDFS.
- execute SQL queries (Hive as syntax)
Spark SQL helps ingesting data from structured sources (source that provide a schema), such as:
- Database (Hive, …)
Spark SQL is the standard for SQL on Spark. Hive on Spark is similar to SparkSQL but aims to leverage existing investments in Hive (security, …) on Spark. They are two different components with two different code base.
This library is part of the core distribution since Spark 1.0 (April 2014)
2 - Articles Related
3 - Architecture
This module provides support for executing relational queries expressed in either :
- or the DataFrame/Dataset API.
Spark SQL is broken up into four subprojects:
- Catalyst (sql/catalyst) - An implementation-agnostic framework for manipulating trees of relational operators and expressions.
- Execution (sql/core) - A query planner / execution engine for translating Catalyst's logical query plans into Spark RDDs. This component also includes a new public interface, SQLContext, that allows users to execute SQL or LINQ statements against existing RDDs and Parquet files.
- Hive Support (sql/hive) - Includes an extension of SQLContext called HiveContext that allows users to write queries using a subset of HiveQL and access data from a Hive Metastore using Hive SerDes. There are also wrappers that allow users to run queries that include Hive UDFs, UDAFs, and UDTFs.
4 - Management
4.1 - Client
You can also interact with the SQL interface over:
- Spark - spark-sql cli (locally)