Run the os command and enter the value of the hive variable

Is it possible to run something like this in the Hive CLI ?

I am trying to pass the content of a file as a variable to another request.

set column_list=!cat /home/user/filename.lst ;
create table tabname as select $column_list from ...

      

0


source to share


2 answers


If you have a request file you pass the variables as hiveconf hive -hiveconf var1 = abcd -f file.txt



or you can build your query and then pipe it to the hive cli using -e hive -e "create table ..."

0


source


file filename.lst

line

      

make a file test.sh,

temp=$(cat /home/user/filename.lst)

hive -f test.hql -hiveconf var=$temp

      

make another test.hql file



create table test(${hiveconf:var} string);

      

at the terminal

sh -x test.sh

      

It will pass the string test.hql and create a table with the string as column;

note - all files must be in the same directory. This script only passes one variable.

0


source







All Articles