<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Ambari Hive View API post? in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-Hive-View-API-post/m-p/230299#M69874</link>
    <description>&lt;P&gt;I've seen little documentation on Hive View Rest API here&lt;/P&gt;&lt;P&gt;&lt;A href="https://cwiki.apache.org/confluence/display/AMBARI/View+API" target="_blank"&gt;https://cwiki.apache.org/confluence/display/AMBARI/View+API&lt;/A&gt;&lt;/P&gt;&lt;P&gt;It looks like this is mostly to pull information out of ambari Views.  I'm interested in posting to Ambari Hive View so I can import a bunch of saved queries.  Is this something supported by the API and if so, where can I find this documented?&lt;/P&gt;</description>
    <pubDate>Wed, 18 Oct 2017 19:24:22 GMT</pubDate>
    <dc:creator>daniel_thomas</dc:creator>
    <dc:date>2017-10-18T19:24:22Z</dc:date>
    <item>
      <title>Ambari Hive View API post?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-Hive-View-API-post/m-p/230299#M69874</link>
      <description>&lt;P&gt;I've seen little documentation on Hive View Rest API here&lt;/P&gt;&lt;P&gt;&lt;A href="https://cwiki.apache.org/confluence/display/AMBARI/View+API" target="_blank"&gt;https://cwiki.apache.org/confluence/display/AMBARI/View+API&lt;/A&gt;&lt;/P&gt;&lt;P&gt;It looks like this is mostly to pull information out of ambari Views.  I'm interested in posting to Ambari Hive View so I can import a bunch of saved queries.  Is this something supported by the API and if so, where can I find this documented?&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2017 19:24:22 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-Hive-View-API-post/m-p/230299#M69874</guid>
      <dc:creator>daniel_thomas</dc:creator>
      <dc:date>2017-10-18T19:24:22Z</dc:date>
    </item>
    <item>
      <title>Re: Ambari Hive View API post?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-Hive-View-API-post/m-p/230300#M69875</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/44374/danielthomas.html" nodeid="44374"&gt;@Daniel Thomas&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Something like following you may try to see if this fulfills your requirement:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;Get the list of "Saved Queries"&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;# curl -u admin:admin -i -H 'X-Requested-By: ambari' -X GET &lt;A href="http://localhost:8080/api/v1/views/HIVE/versions/1.5.0/instances/AUTO_HIVE_INSTANCE/savedQueries" target="_blank"&gt;http://localhost:8080/api/v1/views/HIVE/versions/1.5.0/instances/AUTO_HIVE_INSTANCE/savedQueries&lt;/A&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;BR /&gt;Posting the Saved Queries Involves two steps &lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Step-1). &lt;/STRONG&gt; Place your hive queries into the HDFS using API call as following:&lt;/P&gt;&lt;PRE&gt;# curl -u admin:admin -i -H 'X-Requested-By: ambari' -H 'Content-Type: application/json' -X PUT -d '{"file":{"fileContent":"SELECT * FROM store LIMIT 300;","hasNext":false,"page":0,"pageCount":1}}' &lt;A href="http://localhost:8080/api/v1/views/HIVE/versions/1.5.0/instances/AUTO_HIVE_INSTANCE/resources/file/%2Fuser%2Fadmin%2Fhive%2Fjobs%2Fhive-job-103-2017-10-18_12-09%2Fquery.hql" target="_blank"&gt;http://localhost:8080/api/v1/views/HIVE/versions/1.5.0/instances/AUTO_HIVE_INSTANCE/resources/file/%2Fuser%2Fadmin%2Fhive%2Fjobs%2Fhive-job-103-2017-10-18_12-09%2Fquery.hql&lt;/A&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;Step-2).&lt;/STRONG&gt;  Now use the same HDFS path from the step1 to save the query as following for Posting "Saved Queries"&lt;/P&gt;&lt;PRE&gt;# curl -u admin:admin -i -H 'X-Requested-By: ambari'  -H 'Content-Type: application/json' -X POST -d '{"savedQuery":{"dataBase":"foodmart","title":"store sample query1","queryFile":"/user/admin/hive/jobs/hive-job-103-2017-10-18_12-09/query.hql","owner":"admin","shortQuery":null}}'  &lt;A href="http://localhost:8080/api/v1/views/HIVE/versions/1.5.0/instances/AUTO_HIVE_INSTANCE/savedQueries" target="_blank"&gt;http://localhost:8080/api/v1/views/HIVE/versions/1.5.0/instances/AUTO_HIVE_INSTANCE/savedQueries&lt;/A&gt;&lt;/PRE&gt;&lt;P&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2017 19:45:55 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-Hive-View-API-post/m-p/230300#M69875</guid>
      <dc:creator>jsensharma</dc:creator>
      <dc:date>2017-10-18T19:45:55Z</dc:date>
    </item>
    <item>
      <title>Re: Ambari Hive View API post?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-Hive-View-API-post/m-p/230301#M69876</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/44374/danielthomas.html" nodeid="44374"&gt;@Daniel Thomas&lt;BR /&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Additionally if you are planning to Migrate from Hive View 1.0 / 1.5 to  Hive View 2.0 then you might want to take a look at the following API call:&lt;BR /&gt;&lt;A href="https://docs.hortonworks.com/HDPDocuments/Ambari-2.5.2.0/bk_ambari-views/content/hive_upgrade_your_view.html" target="_blank"&gt;https://docs.hortonworks.com/HDPDocuments/Ambari-2.5.2.0/bk_ambari-views/content/hive_upgrade_your_view.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/44374/danielthomas.html" nodeid="44374"&gt;&lt;/A&gt; &lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2017 19:50:29 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-Hive-View-API-post/m-p/230301#M69876</guid>
      <dc:creator>jsensharma</dc:creator>
      <dc:date>2017-10-18T19:50:29Z</dc:date>
    </item>
    <item>
      <title>Re: Ambari Hive View API post?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-Hive-View-API-post/m-p/230302#M69877</link>
      <description>&lt;P&gt;@&lt;A href="https://community.hortonworks.com/users/3418/jsensharma.html"&gt;Jay SenSharma&lt;/A&gt;, this is great stuff.  Thank you for your super-fast response.&lt;/P&gt;&lt;P&gt;Presumably this works the same for Hive 2, just change the path from /api/v1/views/HIVE/versions/1.5.0/instances/AUTO_HIVE_INSTANCE/ to /api/v1/views/HIVE/versions/2.0.0/instances/AUTO_HIVE20_INSTANCE/&lt;/P&gt;&lt;P&gt;-Dan&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2017 19:56:58 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-Hive-View-API-post/m-p/230302#M69877</guid>
      <dc:creator>daniel_thomas</dc:creator>
      <dc:date>2017-10-18T19:56:58Z</dc:date>
    </item>
    <item>
      <title>Re: Ambari Hive View API post?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-Hive-View-API-post/m-p/230303#M69878</link>
      <description>&lt;P&gt;Oh, and what I'm actually doing is migrating saved queries from Cloudera/Hue to Amabri Hive View.  I found I can easily export queries to a list of JSON in Hue, but I don't see any native way of importing those to Ambari, so I'm going to try to load them via the Rest API using Python.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2017 20:00:01 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-Hive-View-API-post/m-p/230303#M69878</guid>
      <dc:creator>daniel_thomas</dc:creator>
      <dc:date>2017-10-18T20:00:01Z</dc:date>
    </item>
    <item>
      <title>Re: Ambari Hive View API post?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-Hive-View-API-post/m-p/230304#M69879</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/44374/danielthomas.html" nodeid="44374"&gt;@Daniel Thomas&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Yes Based on your Hive View version you will need to make the following changes:&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;1.5.0 =&amp;gt;  &lt;/STRONG&gt;Need to be replaced with your view version (like 2.0.0)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;AUTO_HIVE_INSTANCE =&amp;gt;&lt;/STRONG&gt; This is the View Instance Name, Which might be different in your case. For example if you are using default Hive View 2.0 instance then the default view name should be "AUTO_HIVE20_INSTANCE"  (if you have multiple View 2.0 instances then you will need to replace this with your own Hive View 2.0 instance name)&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2017 20:03:15 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-Hive-View-API-post/m-p/230304#M69879</guid>
      <dc:creator>jsensharma</dc:creator>
      <dc:date>2017-10-18T20:03:15Z</dc:date>
    </item>
    <item>
      <title>Re: Ambari Hive View API post?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-Hive-View-API-post/m-p/230305#M69880</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/44374/danielthomas.html" nodeid="44374"&gt;@Daniel Thomas&lt;/A&gt;
&lt;/P&gt;&lt;P&gt;If you are planning to migrate from Hue to Views then you should refer to this article as well:  &lt;A href="https://community.hortonworks.com/articles/54146/migrating-hue-to-ambari-views-24.html" target="_blank"&gt;https://community.hortonworks.com/articles/54146/migrating-hue-to-ambari-views-24.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;More details on&lt;STRONG&gt; "Hue to View Migration"&lt;/STRONG&gt; can be found here: &lt;A href="https://docs.hortonworks.com/HDPDocuments/Ambari-2.5.2.0/bk_ambari-views/content/configuring_your_cluster_for_htv_migration.html" target="_blank"&gt;https://docs.hortonworks.com/HDPDocuments/Ambari-2.5.2.0/bk_ambari-views/content/configuring_your_cluster_for_htv_migration.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2017 20:05:30 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-Hive-View-API-post/m-p/230305#M69880</guid>
      <dc:creator>jsensharma</dc:creator>
      <dc:date>2017-10-18T20:05:30Z</dc:date>
    </item>
    <item>
      <title>Re: Ambari Hive View API post?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-Hive-View-API-post/m-p/230306#M69881</link>
      <description>&lt;P&gt;Ah, yes, I also looked at this as well and found I'd actually have to migrate the Hue database first as it currently uses the embedded Sqlite3 database, which doesn't support remote access.  This was encouraging though and is likely very helpful for those who configured thier Hue for an external database in the first place.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2017 20:13:19 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-Hive-View-API-post/m-p/230306#M69881</guid>
      <dc:creator>daniel_thomas</dc:creator>
      <dc:date>2017-10-18T20:13:19Z</dc:date>
    </item>
    <item>
      <title>Re: Ambari Hive View API post?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-Hive-View-API-post/m-p/230307#M69882</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/3418/jsensharma.html" nodeid="3418"&gt;@Jay SenSharma&lt;/A&gt; I'm having trouble with this still.  I tried what I actually wanted to post and, as below, tried with your sample.  In both cases, I got a 500 server error.  What am I doing wrong here?&lt;/P&gt;&lt;P&gt;curl -u admin:admin -i -H 'X-Requested-By: ambari' -H 'Content-Type: application/json' -X PUT -d '{"file":{"fileContent":"SELECT * FROM store LIMIT 300;","hasNext":false,"page":0,"pageCount":1}}' &lt;A href="http://hdp-node00:8080/api/v1/views/HIVE/versions/2.0.0/instances/AUTO_HIVE20_INSTANCE/resources/file/%2Fuser%2Fadmin%2Fhive%2Fjobs%2Fhive-job-103-2017-10-18_12-09%2Fquery.hql" target="_blank"&gt;http://hdp-node00:8080/api/v1/views/HIVE/versions/2.0.0/instances/AUTO_HIVE20_INSTANCE/resources/file/%2Fuser%2Fadmin%2Fhive%2Fjobs%2Fhive-job-103-2017-10-18_12-09%2Fquery.hql&lt;/A&gt; &lt;/P&gt;&lt;P&gt;HTTP/1.1 500 Server Error
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Pragma: no-cache
Set-Cookie: AMBARISESSIONID=1woe7sttjidcw1rpi053bemdq5;Path=/;HttpOnly
User: admin
Content-Type: text/plain;charset=ISO-8859-1
Content-Length: 48
{
  "status": 500,
  "message": "Server Error"
}&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2017 19:20:09 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-Hive-View-API-post/m-p/230307#M69882</guid>
      <dc:creator>daniel_thomas</dc:creator>
      <dc:date>2017-10-19T19:20:09Z</dc:date>
    </item>
    <item>
      <title>Re: Ambari Hive View API post?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-Hive-View-API-post/m-p/230308#M69883</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/44374/danielthomas.html" nodeid="44374"&gt;@Daniel Thomas&lt;/A&gt;&lt;/P&gt;&lt;P&gt;For Hive View 2.0 you can try something like following:
&lt;/P&gt;&lt;PRE&gt;# curl -u admin:admin -i -H 'X-Requested-By: ambari' -H 'Content-Type: application/json' -X POST -d '{"savedQuery":{"dataBase":"default","title":"Worksheet1","queryFile":"","owner":null,"shortQuery":"select * from customer LIMIT 3;"}}' "http://localhost:8080/api/v1/views/HIVE/versions/2.0.0/instances/AUTO_HIVE20_INSTANCE/savedQueries"&lt;/PRE&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The saved script will be automatically stored inside the HDFS location something like "/user/admin/hive/scripts" (assuming that admin user is running the hive query)&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;Similarly if the user "maria_dev" runs the API call then the Saved Query SQL dat will be stored in the HDFS directory "/user/maria_dev/hive/scripts" directory:&lt;/P&gt;&lt;PRE&gt;# curl -u maria_dev:maria_dev -i -H 'X-Requested-By: ambari' -H 'Content-Type: application/json' -X POST -d '{"savedQuery":{"dataBase":"default","title":"Worksheet1","queryFile":"","owner":null,"shortQuery":"select * from customer LIMIT 5;"}}' "http://localhost:8080/api/v1/views/HIVE/versions/2.0.0/instances/AUTO_HIVE20_INSTANCE/savedQueries"&lt;/PRE&gt;&lt;P&gt;.&lt;/P&gt;</description>
      <pubDate>Sat, 21 Oct 2017 18:04:38 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-Hive-View-API-post/m-p/230308#M69883</guid>
      <dc:creator>jsensharma</dc:creator>
      <dc:date>2017-10-21T18:04:38Z</dc:date>
    </item>
    <item>
      <title>Re: Ambari Hive View API post?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-Hive-View-API-post/m-p/230309#M69884</link>
      <description>&lt;P&gt;This totally worked!  Thanks &lt;A rel="user" href="https://community.cloudera.com/users/3418/jsensharma.html" nodeid="3418"&gt;@Jay SenSharma&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;Note:  I use the previous saved query name from my json source file as the "title" in the new saved query.  This allowed me to uniquely identify each query in the UI.  If I ever revisit this code, I may also need to query Rest to see if a specific query already exists and replace it or increment the title name or something.&lt;/P&gt;&lt;P&gt;-Dan&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 23:25:16 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-Hive-View-API-post/m-p/230309#M69884</guid>
      <dc:creator>daniel_thomas</dc:creator>
      <dc:date>2017-10-23T23:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: Ambari Hive View API post?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-Hive-View-API-post/m-p/230310#M69885</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/44374/danielthomas.html" nodeid="44374"&gt;@Daniel Thomas&lt;BR /&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Good to know that it worked for you.  As the original issue is resolved, hence it will be also great if you can mark this HCC thread as Answered by clicking on the "Accept" Button on the correct answer. That way other HCC users can quickly find the solution when they encounter the same issue.&lt;/P&gt;&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/44374/danielthomas.html" nodeid="44374"&gt;&lt;/A&gt; &lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 23:53:52 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Ambari-Hive-View-API-post/m-p/230310#M69885</guid>
      <dc:creator>jsensharma</dc:creator>
      <dc:date>2017-10-23T23:53:52Z</dc:date>
    </item>
  </channel>
</rss>

