2014-10-10 51 views
3

我在hcatalog中有一個表,它有3個字符串列。當我嘗試來連接字符串,我收到以下錯誤:字符串串聯不能在豬中工作

A = LOAD 'default.temp_table_tower' USING org.apache.hcatalog.pig.HCatLoader() ; 
B = LOAD 'default.cdr_data' USING org.apache.hcatalog.pig.HCatLoader(); 
c = FOREACH A GENERATE CONCAT(mcc,'-',mnc) as newCid; 

Could not resolve concat using imports: [, java.lang., org.apache.pig.builtin., org.apache.pig.impl.builtin.]

Could not infer the matching function for org.apache.pig.builtin.CONCAT as multiple or none of them fit. Please use an explicit cast

可能是什麼問題的根本原因?

+3

Pig do U使用什麼版本?因爲在0.13版本中有超過兩個參數的CONCAT可用。在以前的版本中,您必須使用CONCTAT(CONCAT(mcc,' - '),mnc) – 2014-10-10 12:55:34

+0

[CONCAT]的引用(https://pig.apache.org/docs/r0.13.0/func.html#concat),它支持兩個以上的參數和[CONCAT](http://pig.apache.org/docs/r0.7.0/piglatin_ref2.html#CONCAT),它不支持多個參數 – 2014-10-10 14:47:50

回答

0

可能會幫助進行連結豬

DATA1包含:

(Maths,abc) 
(Maths,def) 
(Maths,ef) 
(Maths,abc) 
(Science,ac) 
(Science,bc) 
(Chemistry,xc) 
(Telugu,xyz) 

考慮架構爲子:數學,數學,科學....等和名稱:ABC, DEF,ef..etc

X = FOREACH data1 GENERATE CONCAT(sub,CONCAT('@',name)); 

O/X的P爲:

([email protected]) 
([email protected]) 
([email protected]) 
([email protected]) 
([email protected]) 
([email protected]) 
([email protected]) 
([email protected])