Starting Hive-Client Programmatically With Scala

Starting Hive-Client Programmatically With Scala

http://ift.tt/2qIO7o8

Hive defines a simple SQL-like query language for querying and managing large datasets called Hive-QL (HQL). It’s easy to use if you’re familiar with SQL Language. Hive allows programmers who are familiar with the language to write the custom MapReduce framework to perform more sophisticated analyses.

In this blog, we will learn how to create a Hive client with Scala to execute basic HQL commands. First, create a Scala project with Scala 2.12 version.

Now, add the following properties in your build.sbt file:

In my case, I am using Hive 2.1.1; you can use any. Let the dependencies be resolved. Now, add a Scala class in your project named hiveclient:

It has one public method, executeHQL, that calls the private method getDriver to get the hiveDriver instance and execute HQL with it. This method will give back the response code back.

Now, write the test case to test this Hive client:

Now, run these test cases:

java

via DZone.com Feed https://dzone.com

May 15, 2017 at 12:27PM

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s