Support Questions
Find answers, ask questions, and share your expertise

Can Ambari Hive Views Queries Shared between users ?

Expert Contributor

Can Ambari Hive Views Queries be shared between user ?

1 REPLY 1

Re: Can Ambari Hive Views Queries Shared between users ?

Super Mentor

@nyakkanti

No, Saved Queries are user specific. The "Saved Queries" tab shows all the queries that have been saved by the current user.

Every "Logged In" users saved queries are stored in their own specific directories:

# curl -u admin:admin -H "X-Requested-By: ambari" -X GET http://localhost:8080/api/v1/views/HIVE/versions/2.0.0/instances/AUTO_HIVE20_INSTANCE/savedQueries

{
  "savedQueries": [
    {
      "queryFile": "/user/admin/hive/scripts/hive-query-1-2017-06-18_06-04.hql",
      "dataBase": "default",
      "title": "W1",
      "shortQuery": "select * from customer;",
      "id": "1",
      "owner": "admin"
    }
  ]
}

.

Similarly for "hive1" user it will be stored in "/user/hive1/hive/scripts"

# curl -u hive1:hive1 -H "X-Requested-By: ambari" -X GET http://localhost:8080/api/v1/views/HIVE/versions/2.0.0/instances/AUTO_HIVE20_INSTANCE/savedQueries

{
  "savedQueries": [
    {
      "queryFile": "/user/hive1/hive/scripts/hive-query-2-2017-06-18_06-15.hql",
      "dataBase": "default",
      "title": "cust1query",
      "shortQuery": "select * from customer where custname \u003d \u0027C",
      "id": "2",
      "owner": "hive1"
    }
  ]
}

.

The information about the "Saved Query Owner" and the *.hsql file path is maintained inside the following table (Here there is not Sharing option/attribute available)

ambari=> select * from ds_savedquery_10 ;
 ds_id | ds_database | ds_owner |                        ds_queryfile                        |               ds_shortquery                |  ds_title  
-------+-------------+----------+------------------------------------------------------------+--------------------------------------------+------------
 1     | default     | admin    | /user/admin/hive/scripts/hive-query-1-2017-06-18_06-04.hql | select * from customer;                    | W1
 2     | default     | hive1    | /user/hive1/hive/scripts/hive-query-2-2017-06-18_06-15.hql | select * from customer where custname = 'C | cust1query

.