Starting Hive-Client Programmatically With Scala
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
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
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:
via DZone.com Feed https://dzone.com
May 15, 2017 at 12:27PM