如何传递源命令的直线配置单元变量?

y1aodyip  于 2021-06-24  发布在  Hive
关注(0)|答案(1)|浏览(386)

我试图传递直线变量。源文件名命令无法用值替换变量。相同的命令使用配置单元-f工作。请在下面查找命令。
注:

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} ;

错误

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)

但是hive-f能够替换变量。

hive -f "${PROJECT_DIR}/tmp/create_db_l1_gcb_trxn.hql" --hivevar db_env=${db_env}
o2g1uqev

o2g1uqev1#

我可以用直线连接到Hive,但在那里我无法操作任何东西。下面是访问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"

相关问题