0
的編程蜂巢書中列舉建在蜂巢功能test in
,但它並不明顯如何使用它,我一直無法找到例子如何在內置函數中使用Hive「(val1,val2)」中的測試?
下面是從編程蜂巢的信息:
Return type Signature Description
----------- --------- -----------
BOOLEAN test in(val1, val2, …) Return true if testequals one of the values in the list.
我想知道它是否可以用來說明值是否在Hive數組中。
例如,如果我這樣做了查詢:
hive > select id, mcn from patients limit 2;
id mcn
68900015 ["7382771"]
68900016 ["8847332","60015163","63605102","63251683"]
我希望能夠測試是否這些數字中的一個,說「60015163」是在給定患者的MCN清單。
不知道該怎麼做。
我試過了一些變化,所有這些變化都無法解析。這裏有兩個例子不工作:
select id, test in (mcn, "60015163") from patients where id = '68900016';
select id, mcn from patients where id = '68900016' and test mcn in('60015163');
看起來你是對的。這只是SQL WHERE子句的標準「IN」子句。它只是記錄在一個非常糟糕的方式。此外,我正在使用橫向視圖爆炸,它運作良好,所以謝謝你的答案。 – quux00