2016-05-12 74 views
0

我正在while循环中运行impala查询,并且为此我创建了一个单独的查询文件,并且从我的shell脚本调用它我的问题是,我们可以通过shell变量匹配与查询文件中的黑斑羚查询。通过命令行Impala查询shell变量

A="INSERT_SBP_ME_VS_ME_INCOME_LAST_THIRTY_DAYS_Q"${Count} 
    echo "value of A is $A" 
      source ${SBP2_MNY_IN_LAST_THIRTY_DAYS_QF} 
${IMPALA_CON} -q "${${A}}" 

A value is like INSERT_SBP_ME_VS_ME_INCOME_LAST_THIRTY_DAYS_Q1 (as count is 1) 

I am doing this in this way but getting bad substitution error and I also tried 
    ${IMPALA_CON} -q "${A}" but not getting any successful result 
+0

的shell你正在使用bash或别的东西参数化查询? –

+0

@RamPrasadG我正在使用Bash shell。 –

回答

0

不知道这是你在找什么。
下面是一个示例,你怎么可能有存储在一个文件
这可以通过黑斑羚-shell执行

$ cat test.sql 
select 10 + ${x}; 
$ export x=15 
$ echo "${x}" 
15 
$ query=`eval "echo \"$(<test.sql)\""` 
$ impala-shell <connection> -q "$query"