Support Questions

Find answers, ask questions, and share your expertise

How to fetch total numbers of tables available in a Schema using Rest API search techniques ?

avatar
Expert Contributor

How to get the list pf all the tables available in a particular schema. This Rest API command generally gives the GUID and total count of all tables available in Atlas.

http://hostname:port/api/atlas/entities?type=hive_table

Can we apply some sort of filter on database or schema ?

Thank you,

Subash

1 ACCEPTED SOLUTION

avatar
Super Collaborator

@subash sharma

DSL query : hive_table where db.name="default" lists down all the hive tables in "default" database.

V1 Query which can be used in Atlas 0.7 :

/api/atlas/discovery/search/dsl?query=hive_table+where+db.name%3D%22default%22

View solution in original post

13 REPLIES 13

avatar
Expert Contributor

Right now there isn't a way to sort the output. The consumer of this API will have to do the sorting.

Alternative to this would be to use DSL query. See this page for some samples.

DSL search converts the query into Gremlin query and then fires it on to the database.

Your query would be like this: hive_table orderby name

REST call would be: http://localhost:21000/api/atlas/v2/search/dsl?limit=25&excludeDeletedEntities

Hope this helps.

avatar
Expert Contributor

Hey @Ashutosh Mestry,

I should have mentioned Atlas version as well. I am currently working on Atlas 0.7 and I guess the rest API request which you have mentioned will work on Atlas 0.8. Are there any similar rest API request available for Atlas 0.7 ?

Even if i will search on hive_table orderby name , It will list down all the tables from all schema. I am searching a way to list down list of all tables of a particular schema.

Thank you,

Subash

avatar
Expert Contributor

Like @Ashutosh Mestry said this can be achieved through DSL or Gremlin calls.

from DB select count() as 'count'
from Table select count() as 'count'

Also remember that the count queries are pretty expensive and might take a while to return results as it requires a major graph scan.

avatar
Super Collaborator

@subash sharma

DSL query : hive_table where db.name="default" lists down all the hive tables in "default" database.

V1 Query which can be used in Atlas 0.7 :

/api/atlas/discovery/search/dsl?query=hive_table+where+db.name%3D%22default%22

avatar
Expert Contributor

Bingo, This is what i was looking for !

Thank you @Sharmadha Sainath

avatar
Super Collaborator

Welcome @subash sharma . Please accept the answer if it answered your question.

avatar
Expert Contributor

hey @Sharmadha Sainath, How to increase the limit of tables, I am getting only 100 tables using this script.

I tried using "limit" but limit is not working with 1000, It works when i am limiting the number of tables by giving values below 100.

avatar
Super Collaborator

@subash sharma , add limit parameter like :

/api/atlas/discovery/search/dsl?query=hive_table+where+db.name%3D%22default%22&limit=500

avatar
Super Collaborator

@subash sharma , limit parameter should work . How many tables are there in the database you are querying?