This article will show you how to create a batch file and use Hive shell to execute it.
Steps:
1) Using gedit or any other accessible editor, create a script file with the following commands; be sure to update the table name accordingly.
use default;
select printf(‘output is as follows’);
select * from emp;
2) Save the file in the home directory with the extension .hql, .sql, or .q.
3) To invoke and execute the file in Hive, use the command below.
SOURCE /home/cloudera/sample.sql;
I hope you found the information in this post useful.
Happy learning..!!!