簡體   English   中英

如何正確使用配置單元變量替換

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM