Reply
New Contributor
Posts: 3
Registered: ‎09-11-2017

How to show tables based on the table owner?

Hi All,

 

Is there a way to show tables based on the table owner in Impala?

Expert Contributor
Posts: 125
Registered: ‎07-17-2017

Re: How to show tables based on the table owner?

Hi @lonetiger

What do you mean by table owner ?
If you use apache sentry just login to impala-shell by the user concerned (owner) and execute

show tables;

and you'll see just this user tables

Good luck.

New Contributor
Posts: 3
Registered: ‎09-11-2017

Re: How to show tables based on the table owner?

@AcharkiMed - Thanks for responding to the post.

 

To explain long story short... We are using MicroStrategy Reporting tool with Apache Impala which creates tables while running the reports. Some times if the report fails the drop tables doestnt get executed and it results in junk tables in impala and they never get dropped unless we explicitly drop them.

 

So I wanted to list out the tables which are created by a db login so that I can go ahead drop all the tables which are created by a seperate login.

 

Let me know if you need more info.

 

 

Expert Contributor
Posts: 125
Registered: ‎07-17-2017

Re: How to show tables based on the table owner?

Hi @lonetiger

You can do it by two kind of scripts:
1- show all tables:

SHOW TABLES;

get the list and run this query on all tables:

DESCRIBE FORMATTED tableX;

Then you can get the results and extract the owner, if it's the desired one, drop the table.

2- Connect with your hive metastore DB and get the table list of the owner you want

SELECT "TBL_NAME"
FROM   "TBLS"
WHERE  "OWNER" = 'ownerX';

Then drop them.

Good luck.

Announcements