【详述】使用shell脚本自动执行,向starrocks表中插入数据报错
【背景】shell脚本向starrocks表中插入数据,单独将脚本的sql在starrocks的客户端执行是没有问题的
【业务影响】
【StarRocks版本】2.5.2
【集群规模】3fe(1 follower+2observer)+3be(fe与be混部)
【联系方式】392388393@qq.com
【附件】
执行脚本时报错:
-bash: dim_users_unique: command not found
-bash: name: command not found
-bash: pwdRaw: command not found
-bash: regDate: command not found
-bash: realName: command not found
-bash: gender: command not found
-bash: birthday: command not found
-bash: isMarriaged: command not found
-bash: lastTime: command not found
-bash: isValid: command not found
-bash: diskSpaceAllowed: command not found
-bash: diskSpaceUsed: command not found
-bash: online_time: command not found
-bash: unit_code: command not found
-bash: isPass: command not found
-bash: last_login: command not found
-bash: login_account: command not found
-bash: account_type: command not found
-bash: wx_union_id: command not found
-bash: doc_comment_query_flag: command not found
-bash: ods_users_unique: command not found
ERROR 1064 (HY000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘select’ at line 1
脚本信息是:
#! /bin/bash
ods_to_dim.sh all/表名
#1、判断参数是否传入
if [ $# -lt 1 ]
then
echo “必须至少传入一个表名/all…”
exit
fi
#用户维度表sql语句
dim_users_unique_sql="
insert into dim_users_unique
SELECT
id
,
name
,
pwd
,
pwdRaw
,
regDate
,
realName
,
gender
,
birthday
,
isMarriaged
,
lastTime
,
isValid
,
diskSpaceAllowed
,
diskSpaceUsed
,
online_time
,
unit_code
,
isPass
,
last_login
,
login_account
,
account_type
,
wx_union_id
,
doc_comment_query_flag
from ods_users_unique
;
"
#2、根据第一个参数匹配加载
case $1 in
“all”)
mysql -uroot -h172.30.16.26 -P 19030 -e “use test_house;${dim_users_unique_sql};”
;;
“dim_users_unique”)
mysql -uroot -h172.30.16.26 -P 19030 -e “use test_house;${dim_users_unique_sql};”
;;
*)
echo “表名传入错误…”
;;
esac