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.

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

Solved Go to solution

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

New 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

Accepted Solutions

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

Expert Contributor

@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
13 REPLIES 13
Highlighted

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

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.

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

New 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

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

Rising Star

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.

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

Expert Contributor

@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

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

New Contributor

Bingo, This is what i was looking for !

Thank you @Sharmadha Sainath

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

Expert Contributor

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

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

New 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.

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

Expert Contributor

@subash sharma , add limit parameter like :

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

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

Expert Contributor

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