Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Apache Spark Quick Start Guide

You're reading from  Apache Spark Quick Start Guide

Product type Book
Published in Jan 2019
Publisher Packt
ISBN-13 9781789349108
Pages 154 pages
Edition 1st Edition
Languages
Authors (2):
Shrey Mehrotra Shrey Mehrotra
Profile icon Shrey Mehrotra
Akash Grade Akash Grade
Profile icon Akash Grade
View More author details

Spark SQL

In our previous chapter, we learned about DataFrames and datasets and how we can use or write custom encoders to have type-safe operations on datasets. This chapter explains the SQL component of Spark, which helps developers working on Hive or familiar with RDBMS SQL to use a similar style in Spark.

We will be covering the following topics in this chapter:

  • Spark metastore
  • SQL language manual
  • SQL database using Java Database Connectivity (JDBC)

Spark SQL

Spark SQL is an abstraction of data using SchemaRDD, which allows you to define datasets with schema and then query datasets using SQL. To start with, you just have to type spark-sql in the Terminal with Spark installed. This will open a Spark shell for you.

Spark metastore

To store databases, table names, and schema, Spark installs a default database, metastore.db, at the same location from where you started the SQL shell.

Using the Hive metastore in Spark SQL

Spark provides the flexibility to leverage the existing Hive metastore. This will allow users to access...

Summary

In this chapter, we learned how we can connect Spark to the Hive metastore and use the Spark SQL language to perform DDL operations in Spark. Also, we went through how we can connect Spark SQL to different RDBMS datastores and query tables, which provide DataFrames as results. In the next chapter, we will be studying Spark Streaming, machine learning, and graph analysis.

lock icon The rest of the chapter is locked
You have been reading a chapter from
Apache Spark Quick Start Guide
Published in: Jan 2019 Publisher: Packt ISBN-13: 9781789349108
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}