Impala: Show tables like query

南楼画角 提交于 2021-02-07 14:45:47

问题


I am working with Impala and fetching the list of tables from the database with some pattern like below.

Assume i have a Database bank, and tables under this database are like below.

cust_profile
cust_quarter1_transaction
cust_quarter2_transaction
product_cust_xyz
....
....
etc

Now i am filtering like

show tables in bank like '*cust*'

It is returning the expected results like, which are the tables has a word cust in its name.

Now my requirement is i want all the tables which will have cust in its name and table should not have quarter2.

Can someone please help me how to solve this issue.


回答1:


Execute from the shell and then filter

impala-shell -q "show tables in bank like '*cust*'" | grep -v 'quarter2'



回答2:


Query the metastore

 mysql -u root -p -e "select TBL_NAME from metastore.TBLS where TBL_NAME like '%cust%' and TBL_NAME not like '%quarter2%'";


来源:https://stackoverflow.com/questions/42999498/impala-show-tables-like-query

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!