Get fresh updates from Hortonworks by email

Once a month, receive latest insights, trends, analytics information and knowledge of Big Data.


Get Started


Ready to Get Started?

Download sandbox

How can we help you?

closeClose button
HDP > Develop with Hadoop > Apache Spark

Spark SQL Thrift Server Example

cloud Ready to Get Started?



This is a very short tutorial on how to use SparkSQL Thrift Server for JDBC/ODBC access


This tutorial assumes that you are running an HDP Sandbox.

Please ensure you complete the prerequisites before proceeding with this tutorial.

SparkSQL Thrift Server Example

SparkSQL’s thrift server provides JDBC access to SparkSQL.

Create logs directory

Once logged in the sandbox terminal (command line), change ownership of logs directory from root to spark user:

cd /usr/hdp/current/spark-client
chown spark:hadoop logs

Start Thrift Server

su spark
./sbin/ --master yarn-client --executor-memory 512m --hiveconf hive.server2.thrift.port=10015

Connect to the Thrift Server over Beeline

Launch Beeline:


Connect to Thrift Server and issue SQL commands

On the beeline> prompt type:

!connect jdbc:hive2://localhost:10015


  • This example does not have security enabled, so any username-password combination should work.
  • The connection may take a few seconds to be available in a Sandbox environment.

You should see an output similar to the following:

beeline> !connect jdbc:hive2://localhost:10015
Connecting to jdbc:hive2://localhost:10015
Enter username for jdbc:hive2://localhost:10015:
Enter password for jdbc:hive2://localhost:10015:
Connected to: Spark SQL (version 1.6.2)
Driver: Spark Project Core (version
0: jdbc:hive2://localhost:10015>

Once connected, try show tables:

show tables;

You should see an output similar to the following:

| tableName  | isTemporary  |
| sample_07  | false        |
| sample_08  | false        |
| testtable  | false        |
3 rows selected (2.399 seconds)
0: jdbc:hive2://localhost:10015>

Type Ctrl+C to exit beeline.

Stop Thrift Server