impala通过命令行查询shell变量

rqmkfv5c  于 2021-05-29  发布在  Hadoop
关注(0)|答案(1)|浏览(468)

我在while循环中运行一个impala查询,为此我创建了一个单独的查询文件,并从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
dw1jzc5e

dw1jzc5e1#

不确定这是不是你要找的。
下面是一个如何将参数化查询存储在文件中的示例
可以通过 Impala 壳来执行

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

相关问题