Good Question Nishant.
Stored Procedures are nothing bunch of SQL queries stored on the database side. The stored procedures provide a way to pass an argument and substitute a variable. So, you can call stored procedures from remote with arguments.
Here are some of the solutions:
1. Use HPL / SQL
HPL/SQL provides the functionality of stored procedures. It is now available as part of HDP (HortonWorks Data Platform) 2.6.
See: http://www.hplsql.org/start
We are working on upgrading CloudxLab to next version. The HPL/SQL will be available in that.
So far I have tried the following but has not worked because of some dependencies:
wget http://www.hplsql.org/downloads/hplsql-0.3.31.tar.gz
gunzip hplsql-0.3.31.tar.gz
tar -xvf hplsql-0.3.31.tar
cd hplsql-0.3.31
export HADOOP_CLASSPATH=`hadoop classpath`
./hplsql --version
./hplsql -e "select * from employees"
2. Using Views
Mostly, we want to create stored procedures in analytical environments in order to make the queries simplified and be able to use the same piece of logic in many other places. Same can be achieved to some extent using Views.
Also, views are stored in the database.
3. Using UDF - User Defined Functions
Unlike the name suggests, UDF is not really like an stored procedure but it does let you define your custom logic in Java.
4. Save it in a file and load it.
Alternatively, if your objective is to keep the SQL separate from the actual code. Keep SQL in a separate text file and load it using Java and send it to Hive after substituting the params.