Set the variable this way:
#!/bin/bashcnt=3echo "Executing the hive query - starts"hive -hiveconf num=$cnt -e ' set num; select * from demodb.demo_table limit ${hiveconf:num}'echo "Executing the hive query - ends"
This works, if put in a file named hivetest.sh, then invoked with sh hivetest.sh:
hivetest.sh
sh hivetest.sh
cnt=2hive -e "select * from demodb.demo_table limit $cnt"
You are using single quotes instead of double.Using double quotes for OPTION #1 also works fine.
hadoop@osboxes:~$ export val=2;
hadoop@osboxes:~$ hive -e "select * from bms.bms1 where max_seq=$val";
or
vi test.sh#########export val=2hive -e "select * from bms.bms1 where max_seq=$val";#####################