gpt4 book ai didi

unix - Hive 变量替换在 hive -e 命令中不起作用

转载 作者:可可西里 更新时间:2023-11-01 16:22:05 26 4
gpt4 key购买 nike

我正在尝试使用 Hive 变量。

如果我登录 Hive 并使用:

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

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

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

最佳答案

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};'

关于unix - Hive 变量替换在 hive -e 命令中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15240300/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com