Invoke and Execute a Script File in Hive

This article will show you how to create a batch file and use Hive shell to execute it.

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..!!!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s