c# – Connecting to HIVE Hadoop

Question:

There is a database that is located on the server, I go there through a browser like http://00.00.00.000:0000 I would like to connect to Hive Hadoop via .net c #. Tried it via Microsoft.Hadoop.Hive;

var db = new HiveConnection(
webHCatUri: (new Uri("http://00.00.00.000:0000/accounts/login/")),
userName: "логин", password: "пароль");
var result = db.ExecuteHiveQuery(query: "select count(*) from edw_uat_odl.t_ABONENT where package_id = 15");
result.Wait();

Doesn't return any result in db hostname = null either.

When you login through the browser POST sends parameters

csrfmiddlewaretoken "7e9001a3c2801f25097c11e119745e31"
username    "логин"
password    "пароль"
next    "/about/"

When I make a request in Hive itself via Besswax, I send parameters

csrfmiddlewaretoken "7e9001a3c2801f25097c11e119745e31"
query-database  "default"
settings-0-key  "mapreduce.job.queuename"
settings-0-value    "EK"
settings-0-_exists  "True"
query-is_parameterized  "on"
query-download_format   "None"
query-query "set+hive.mapred.mode=unstrict;set+mapreduce.job.queuename=EK;select+count(*)+    from+edw_uat_odl.t_ABONENT+where+package_id+=+15"
settings-next_form_id   "1"
file_resources-next_form_id "0"
functions-next_form_id  "0"
button-submit   "Execute"

In general, please tell me how to send requests to hive and get answers.

Answer:

I bet that the problem is:

webHCatUri: (new Uri("http://00.00.00.000:0000/accounts/login/")),

– judging by /accounts/login , you copied this from the browser in which you opened something like Hue.

WebHCat is not at all what it is. REST API for HCatalog: https://cwiki.apache.org/confluence/display/Hive/WebHCat+UsingWebHCat

In the working examples, you can see that if the WebHCat status is available at http://www.myserver.com/templeton/v1/status , then in webHCatUri: new Uri("http://www.myserver.com")

Accordingly, to debug the connection, you need to use curl: https://docs.microsoft.com/en-us/azure/hdinsight/hadoop/apache-hadoop-use-hive-curl

Scroll to Top