有关如何在shell脚本中运行斑羚壳 [英] about how to run impala-shell within a shell script

查看:260
本文介绍了有关如何在shell脚本中运行斑羚壳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图执行此bash的code时,我有一个问题:

i have a problem when trying to execute this bash code:

function createImpalaPartition() {

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

actual_full=$(date -d@"$period_id" +%Y/%m/%d/%H/%M/)
template="use c2d;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'"

echo "template is $template";
#impala-shell -V -i $node -d $database -q $template
impala-shell -V -i $node -q $template
}

这是我如何调用它:

createImpalaPartition $actual $impalaDatabase $impalaNode

其中,

actual=$(date +'%s')
impalaDatabase="dbName"
impalaNode="name_of_the_node"

脚本的执行返回:

the execution of the script returns:

[core@dub-vcd-vms170 ~]$ createImpalaPartition $actual $impalaDatabase $impalaNode
template is use c2d;create EXTERNAL TABLE exptopology_1428326587 (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/2015/04/06/14/23/'
Error, could not parse arguments "c2d;create EXTERNAL TABLE exptopology_1428326587 (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/2015/04/06/14/23/'"
 Usage: impala_shell.py [options]

正如你所看到的,我有使用shell脚本创建表。

As you can see, i have to create tables using a shell script.

更新:

按照此<一个href=\"http://stackoverflow.com/questions/28419361/is-there-any-way-to-run-impala-shell-with-sql-script-with-parameters\">link,我可以看到,黑斑羚壳可以用这种方式,但我没有使用正确的PARAMS。

following this link, i can see that impala-shell can be used that way, but i am not using the correct params.

我已经代替-q -f,同样的错误仍然存​​在。任何人可以帮助我,好吗?

I have used -f instead of -q, the same error remains. Can anybody help me, please?

推荐答案

您需要引用 $模板的扩展整个字符串被视为一个参数到黑斑羚壳

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 -q "$template"

这篇关于有关如何在shell脚本中运行斑羚壳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆