Support Questions

Find answers, ask questions, and share your expertise

Atlas REST API search of a table fails

avatar
Expert Contributor

I want to allow users that store data on our HDP 2.6.3 cluster, to tag to their data in Atlas with the push a button. So I'm preparing the REST API commands for that. And because Atlas is not implemented here, I'm trying this on a HDP 2.6.3 Sandbox on a VirtualBox.

Atlas is running and the REST API works. For example, I can run this:

curl -iv -X GET http://sandbox.hortonworks.com:21000/api/atlas/entities?type=hive_table

And this results in:

{
"requestId": "pool-2-thread-4 - d7ab6dc3-2464-482d-b78b-24f5e14bfd49",
"typeName": "hive_table",
"results": [
"faedff26-819c-47ee-9cdf-77b4ba8bc547",
"dfbe373d-b672-418e-8f45-5e285b64dd7d",
"f8861c18-6ba2-455d-9024-96abf01387f1",
"9503d0e1-37d7-4456-8b79-30dda3199f67",
"c6fc7997-648a-4154-9bca-b265f4882ae5",
"155265ec-dbfe-4951-b051-2b09c47a6c7f",
"908cba22-cfa3-429e-a116-51dcdcbfb003",
"8de87c74-3c5d-4b5c-8218-316f2b785f5d",
"c87f4c84-54e7-4c07-ac77-f32811b40fa5",
"aaabeeb3-7528-4f76-8f65-443d26bb266e",
"59234a6b-7d3f-415f-b430-aae2074a0bb0",
"83cd29e8-cca9-4595-9d3b-8479cd2fc3ee",
"70f945be-7c3a-4580-86ac-695b345d0d7f"
],
"count": 13
}

Now I want to search for a Hive table and I just can't seem to get that working. Just to prove the table is there, here is a screenshot from the Atlas GUI:

45407-atlas-search-advanced-hive-table.pngatlas-search-advanced-hive-table.png(30.6 kB)

I've tried many variations of the DSL search. None of them work. These are just a couple of the many variations that I've tried:

curl -iv -u holger_gov:holger_gov -X GET http://sandbox.hortonworks.com:21000/api/atlas/discovery/search/dsl?query=hive_table+where+name='asteroids'

Message: {"error":"Invalid expression : hive_table where name=asteroids"}

curl -iv -u holger_gov:holger_gov -X GET http://sandbox.hortonworks.com:21000/api/atlas/v2/search/dsl?query=hive_table+where+name='asteroids'

Message: There was an error processing your request. It has been logged (ID 7da439947f22992b).

curl -iv -u holger_gov:holger_gov -X GET --header 'Accept: text/html' 'http://sandbox.hortonworks.com:21000/v2/search/dsl?query=name%3D'asteroids''

Message:

<body><h2>HTTP ERROR 404</h2><p>Problem accessing /v2/search/dsl. Reason:<pre>  Not Found</pre></p><hr><i><small>Powered by Jetty://</small></i><hr/></body>
curl -iv -u holger_gov:holger_gov -X GET http://sandbox.hortonworks.com:21000/api/atlas/discovery/search/dsl?query=hive_table+where+name='asteroids'

Message: {"error":"Invalid expression : hive_table where name=asteroids"}

curl -iv -u holger_gov:holger_gov -X GET http://sandbox.hortonworks.com:21000/api/atlas/discovery/search/dsl?query=hive_table+where%20name%3D'asteroids'

Result: {"error":"Invalid expression : hive_table where name=asteroids"}

What am I missing here?

45407-atlas-search-advanced-hive-table.png

1 ACCEPTED SOLUTION

avatar
Super Guru

I tried this and it returns only the queried table

curl -X GET \
  'http://sandbox.hortonworks.com:21000/api/atlas/v2/search/dsl?typeName=hive_table&query=where%20name%3D%22asteroids%22' \
  -H 'authorization: Basic YWRtaW46YWRtaW4='

Since the thread was long. I put the correct answer separately. You will find an "Accept" button beside this answer. Please click on it to accept it to make it as Best answer.

Thanks a lot.

View solution in original post

11 REPLIES 11

avatar
Expert Contributor

@Aditya Sirna, I've voted up your answer. Is that what you mean, or is there something else I can do to vote it as best answer?

avatar
Super Guru

I tried this and it returns only the queried table

curl -X GET \
  'http://sandbox.hortonworks.com:21000/api/atlas/v2/search/dsl?typeName=hive_table&query=where%20name%3D%22asteroids%22' \
  -H 'authorization: Basic YWRtaW46YWRtaW4='

Since the thread was long. I put the correct answer separately. You will find an "Accept" button beside this answer. Please click on it to accept it to make it as Best answer.

Thanks a lot.