[英]How to use hive variable substitution rightly
在蜂巢中使用变量替换时,遇到一些错误,但需要您的帮助。
我的代码:
set hievar:b='on t1.id=t2.id where t2.id is null';
select * from t_old as t1 full outer join t_new as t2 ${b};
当我在hive shell中运行此代码时,它给了我一些关于${b}
错误。
我也尝试这样:
set hivevar:c='select * from t_old as t1 full outer join t_new as t2 on t1.id=t2.id where t2.id is null';
${c};
它给了我同样的错误。
修复hivevar
命名空间名称(在您的代码中为hievar
)并删除引号,因为引号也会在Hive中传递。
例:
set hivevar:b=where 1=1; --without quotes
select 1 ${hivevar:b}; --you can do without hivevar: as in your example
结果:
OK
1
Time taken: 0.129 seconds, Fetched: 1 row(s)
第二个例子:
hive> set hivevar:c=select 1 where 1=1;
hive> ${c};
OK
1
Time taken: 0.491 seconds, Fetched: 1 row(s)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.