Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个创建表脚本,其中表名将在运行时确定。如何将值传递给 sql 脚本?
我正在尝试这样的事情
hcat -e "create table ${D:TAB_NAME} (name string)" -DTAB_NAME=person
但我不断收到错误。我能得到正确的语法吗?
尝试这个:
hcat -e 'create table ${hiveconf:TAB_NAME} (name string);' -DTAB_NAME=person2
这里有两点需要注意:
在 shell 中,默认的变量扩展是$这样的,所以${D:TAB_NAME}在传递给 hcat 解析器之前,你的扩展是空的。因此,要么转义,要么$使用强引用使用:''。
$
${D:TAB_NAME}
''
使用hiveconf而不是D变量替换,因为引擎盖下的 hcat 仍在使用 hive 来解析命令。
hiveconf
D