Problem Explanation: Hive Script Execution/hive -e Option/Passing Varaibles To Hive Script
-----------------------A 'n' of hive commands in batch can be stored into a hive script file with a file name with .hive, .sql, .q extensions.
Create a file named myscript.sql
----start of myscript.sql
select cast(t3.stdt as date) from
(select concat(st_dt[2],'-',st_dt[0],'-',st_dt[1]) stdt from customersales.emp_det)t3
---end of myscript.sql
Execute myscript.sql
$HIVE_HOME/bin>hive -S -f myscript1.sql(with silent option)
-------
myscript1.q contents in a file
select cast(t3.stdt as date) from (select concat(st_dt[2],'-',st_dt[0],'-',st_dt[1]) stdt
from
${hiveconf : my_var1})t3
select concat(st_dt[2],'-',st_dt[0],'-',st_dt[1]) from ${hiveconf : my_var1} limit 1;
----end of file myscript1.q
Execute myscript1.q
$HIVE_HOME/bin> hive -S -hiveconf my_var1=customersales.emp_det -f /home/hadoop/Desktop/tempscript1.q
---------
Execute with -e option
$HIVE_HOME/bin>hive -S -e "select cast(t3.stdt as date) from (select concat(st_dt[2],'-',st_dt[0],'-',st_dt[1]) stdt from customersales.emp_det)t3 ;"
No comments:
Post a Comment