Support Questions

Find answers, ask questions, and share your expertise

Get the location of the table in HQL




I am invoking a hql script from .ksh. The hql is used to format data from input files(.csv).  


So, first I am loading the data to a table(tbl1) who columns are same as the input file. Then I am creating another table(tbl2) with the format I require and performing an insert select from tbl1 to tbl2.  


As the substr of the file name has a field that is required I am retrieving using INPUT__FILE__NAME. But this has the complete hdfs hive table location along with the filename as the data is from tbl1.


Is there a way to only get the table location as parameter in hql?

I couldn't find the metastore database in the core-site.xml. We are using Clodera cluster. Is there a way to find the metastore database so that I can query the table location?


Hope these details helps.


Thank you. 





I don't think there is a direct method to get the location alone (withtout file). It is available in describe formatted <tablename> but not sure how to get it


Since you are using shell, you can apply your customized method like

1. apply instr funtion on INPUT__FILE__NAME to get the last /

2. apply cut function to remove unwanted filename

Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.