Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Query/Insert into Hive using Curl

Query/Insert into Hive using Curl

New Contributor

Hi,

i'm new to ambari and searched for a way to auery/insert into the hive via the ambari REST API. I found some solutions but they don't fit my request.

https://community.hortonworks.com/questions/142862/ambari-hive-view-api-post.html

is there any documentation about query and insert data into the hive? It Would be great to query a table get the resul as a json and insert into a other table.

Or is there a other solution to query/insert/update a hive table via curl?

thx for the help

4 REPLIES 4
Highlighted

Re: Query/Insert into Hive using Curl

Super Mentor

@Gerhard Neuhofer

You can try using the WebHCat to execute your HIve queries something as described in:

https://cwiki.apache.org/confluence/display/Hive/WebHCat+UsingWebHCat

.

Example:

# curl -s -d user.name=ctdean \
       -d rename=test_table_2 \
       'http://${WEBHCAT_SERVER}:50111/templeton/v1/ddl/database/default/table/test_table'

OR

# curl -s -d execute="select+*+from+sample_08;" \  
     -d statusdir="output" \  
     'http://${WEBHCAT_SERVER}:50111/templeton/v1/hive?user.name=root'

.

Highlighted

Re: Query/Insert into Hive using Curl

New Contributor

Hi,

thx for the quick reply.

is it also posible to run complex queries? I tried different tool but they are unable to do complex queries (queries containing joins)

thx

Highlighted

Re: Query/Insert into Hive using Curl

Super Mentor

@Gerhard Neuhofer

There are many options available to select/insert/update data to/from hive table like using Beeline, Hive CLI, Curl (webhcat), Ambari Hive Views... etc

However if you have a very specific requirement to do it using "Curl" (rest API) then the option will be bit limited.

If you want to use web based approach then i will suggest using Ambari Hive Views: https://docs.hortonworks.com/HDPDocuments/Ambari-2.6.1.5/bk_ambari-views/content/configuring_hive_vi...

Highlighted

Re: Query/Insert into Hive using Curl

New Contributor

thx

i'll have a look

Don't have an account?
Coming from Hortonworks? Activate your account here