run os command and set out put to hive variable

2019-08-29 11:50发布

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

I am trying to pass file contents as a variable to another query.

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

标签: hive hiveql
2条回答
该账号已被封号
2楼-- · 2019-08-29 12:12

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

or you can construct your query and then pass it to hive cli using -e hive -e "create table ..."

查看更多
Juvenile、少年°
3楼-- · 2019-08-29 12:27

file filename.lst

line

make a file test.sh,

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

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

make a another file test.hql

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

on terminal

sh -x test.sh

It will pass the line to the test.hql and it will create a table with line as column;

note- all files should be in same directory .This script is passing only one variable.

查看更多
登录 后发表回答