I have a sample.hql file which contains below lines.
desc db.table1;
desc db.table2;
desc db.table3;
I am trying to run it from shell command I want to find out if a particular column is present in the table or not For eg-If col_1 is present in table1 the output should say col1_1 is found in db.table1
I am not sure how to find it. I am executing below command
hive -f sample.hql | grep -q "<column_name>"
But I am not sure how to get the db and table name from each executing line.
You can make grep show you before
-Band after-A. The below command would show you 10 lines before. This likely will get the job done quick and dirty.If you wanted to be a little more careful you might try a for loop instead that feeds the lines to hive one at a time. If it finds the column it will echo the table it found the column in. ( the '&&' only executes code if the previous command was successful)