1

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}
user3858193
  • 1,320
  • 5
  • 18
  • 50

1 Answers1

0

I was able to connect to hive using beeline but don't have access to manipulate anything there. below works for to get access to hive.

#!/bin/bash
echo "Executing the hive query - starts"

beeline --showHeader=true --outputformat=csv2 -u jdbc:hive2://hostname.com:10000 -n username -p password -e "select * from tablename limit 5;"


echo "Executing the hive query - ends"
vikrant rana
  • 4,509
  • 6
  • 32
  • 72
  • 1
    create_db_l1_gcb_trxn.hql contains created db statement and db_env=${db_env} contains an env file. The answer you shared is not going to help here. Thanks for replying quickly. – user3858193 Jul 25 '19 at 10:15
  • 1
    Example below : Hive -f is running fine line=/data/1/appgcb/bin/app_gcb_dw/prccntrl/hql/ct_app_prc_run_cntl_stg_ld.hql param_file=/data/1/appgcb/bin/app_gcb_dw/prccntrl/hql/param_file.hql beeline_url=jdbc:hive2://quickstart.cloudera:10000/default hive -f "${line}" --hivevar param_file=${param_file} beeline -u $beeline_url -f "${line}" --hivevar param_file=${param_file} . – user3858193 Jul 26 '19 at 20:06
  • 1
    Working fine :: hive -f hive_source_test.hql --hivevar hive_var_file=${hive_var_file} Not working: beeline -u ${beeline_url} -f hive_source_test.hql --hivevar hive_var_file=${hive_var_file} . Not able to compile the variable Error: 0: jdbc:hive2://quickstart.cloudera:10000/def> source ${hive_var_file}; Closing: 0: jdbc:hive2://quickstart.cloudera:10000/default – user3858193 Aug 13 '19 at 12:32