Spark - Sql

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.

It

  • execute SQL queries (Hive as syntax)
  • returns the result as a Dataset or DataFrame

Spark SQL helps ingesting data from structured sources (source that provide a schema), such as:

  • JSON,
  • Parquet,
  • 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.

Spark SQL is a library based around an sql in order to create dataset, data frame.

This library is part of the core distribution since Spark 1.0 (April 2014)

Features:

3 - Architecture

This module provides support for executing relational queries expressed in either :

  • SQL
  • 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.
  • HiveServer and CLI support (sql/hive-thriftserver) - Includes support for the SQL CLI (bin/spark-sql) and a HiveServer2 (for JDBC/ODBC) compatible server.

4 - Management

4.1 - Client

You can also interact with the SQL interface over:

4.2 - Language

5 - Documentation / Reference

db/spark/sql/sql.txt · Last modified: 2018/07/21 11:07 by gerardnico