How can I get all the hive tables and its external location,partitions etc ?

There may be some situations where you may need to give all the hive tables created and its location and partitions . This may be for them to create data lineage or for auditing or some other innovative activity. It is very hard to go to each schema and find the details . In situation like this the easy way is to query the hive metastore.

How to get hive metastore credentials , host etc ? You can refer here

You can easily get the information by firing the bellow query 

select 
    distinct d.NAME,t.TBL_NAME,s.LOCATION ,
    SUBSTRING_INDEX(p.PART_NAME,'=',1) as partition_col 
from 
    TBLS t 
    JOIN DBS d ON t.DB_ID=d.DB_ID 
    JOIN PARTITIONS p ON t.TBL_ID=p.TBL_ID
    JOIN SDS s ON t.SD_ID=s.SD_ID

Get the list of tables that is managed by Hive metastore.

Author: user

Leave a Reply