I am trying to pass beeline variable. source file name command is not able to replace the variable with the value. Same command working using hive -f.Please find commands below.
Note:
cat >dev_env.hql
set hivevar:l1_gcb_trxn_db_path="hdfs://quickstart.cloudera:8020/user/hive/warehouse/l1_app_gcb/process/l1_gcb_trxn";
SET hivevar:myvar=dev;
**source /data/1/appgcb/config/"${myvar}"_env.hql;**
create database l1_gcb_trxn
location ${l1_gcb_trxn_db_path} ;
Error
jdbc:hive2://quickstart.cloudera:10000/def> source /data/1/appgcb/config/"${myvar}"_env.hql;
0: jdbc:hive2://quickstart.cloudera:10000/def> create database l1_gcb_trxn
. . . . . . . . . . . . . . . . . . . . . . .> location ${l1_gcb_trxn_db_path} ;
Error: Error while compiling statement: FAILED: ParseException line 2:9 mismatched input '$' expecting StringLiteral near 'location' in database location specification (state=42000,code=40000)
But hive -f is able to replace the variable.
hive -f "${PROJECT_DIR}/tmp/create_db_l1_gcb_trxn.hql" --hivevar db_env=${db_env}