Hive Stored Procedure Intoduction Stored procedure/Function implementation is missing in hive. It is very useful while programming with hive. The key parts of functions are variable assignment and logical operations. Like UDF/UDAF a function name can be bound to a stored procedure, which will take arguments. Sample Stored Procedure: CREATE FUNCTION clean_emp() RETURNS void AS ' DELETE FROM emp WHERE salary < 0; ' LANGUAGE SQL; SELECT clean_emp(); Components To implement stored procedure, the following components are required. 1. SQL Parser To parse the sql function to create a control flow in java. ZQL/inbuilt query parser can be used to accomplish this. 2. Variable storage mechanism Query results should be assigned to specific datastructure. For eg: DECLARE max_id AS INTEGER; SELECT max(id) INTO max_id from purchase_line_item; Execution Model 1. Store function definition in a file eg: maxfinder.sql Shell> hive -storefunction maxfinder.sql Shell> SELECT maxfind(); Shell> .... Challenges Storing results coming out of queries needs to be temporarily stored while assigning to variables. The results will be a big data. Internally a file pointer needs be given against this variable.