1

当我在 hive 中使用变量替换时,我遇到了一些错误,但我需要你的帮助。

我的代码:

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

它给了我同样的错误。

4

1 回答 1

0

修复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)
于 2019-03-20T12:01:04.737 回答