1

我正在尝试使用 Hive 变量。

如果我登录 Hive 并使用:

hive > set a=test_table;
hive > describe ${hiveconf:a};

但是如果从 Shell 尝试相同的命令,它会给出: Parse Error 1:1 cannot identify input near ...

$> hive -e "set a=test_table; describe ${hiveconf:a};"
Parse Error 1:1 cannot recognize input near <EOF>
4

3 回答 3

0
Parameter Expansion
   The `$' character introduces parameter expansion, command substitution, or arithmetic expansion.  The parameter name  or
   symbol  to  be  expanded  may be enclosed in braces, which are optional but serve to protect the variable to be expanded
   from characters immediately following it which could be interpreted as part of the name.

   When braces are used, the matching ending brace is the first `}' not escaped by a backslash or within a  quoted  string,
   and not within an embedded arithmetic expansion, command substitution, or parameter expansion.

   ${parameter}
          The  value  of  parameter  is substituted.  The braces are required when parameter is a positional parameter with
          more than one digit, or when parameter is followed by a character which is not to be interpreted as part  of  its
          name.

所以hive -e 'set a=test_table; desc ${hiveconf:a};'

于 2018-04-10T01:35:05.037 回答
0

尝试这个:

hive --hiveconf a="test_table" -e "描述数据库。${hiveconf:a}"

于 2018-11-03T05:25:02.973 回答
-1

你必须像下面这样编码。

   >a=test_table
   >hive -e "describe $a"

检查语言手册

于 2013-03-06T06:53:18.497 回答