about how to run impala-shell within a shell script

随声附和 提交于 2019-12-04 18:21:27
chepner

You need to quote the expansion of $template for the entire string to be treated as a single argument to impala-shell:

impala-shell -V -i $node "$template"

where -V enables verbose output. For non-verbose (quiet) output replace -V with -q.

aironman

Finally i discover how to resolve my problem.

function createImpalaPartition() {

period_id=$1;
database=$2
node=$3

actual_full=$(date -d@"$period_id" +%Y/%m/%d/%H/%M/)
#UC=$(impala-shell -r -q "select count(1) from table where condition=1" -d $DB -i $HOST -B)
# attention, i have to use this way impala-shell
impala-shell -V -i $node -d $database -q "create EXTERNAL TABLE exptopology_$period_id (child_id bigint,parent_id bigint,level INT) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' WITH SERDEPROPERTIES ('serialization.format'=',', 'field.delim'=',') STORED AS TEXTFILE LOCATION '/hfc/sip/service/topology/$actual_full'"
}

I can't use a template var with the create command, I have to pass the command this way.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!