2016-09-07 116 views
0

我想過濾一個位置變量。位置變量上的豬過濾器

X = FILTER C BY($14 matches '.*USD.*'); 
STORE X into '$output' using PigStorage(','); 

上述說法並不工作,但如果我嘗試只輸出$ 14

E = FOREACH C GENERATE FLATTEN($14); 
STORE C into '$output' using PigStorage(','); 

它工作正常

的樣本數據:

304a285281be,1383027928890968764,receiver,10C,655362,C2,USD811289,1,0,0,ebay_checkout,cc,cc,USD2659,USD120 
304a285281be,1383027928890968764,receiver,10C,655362,C2,USD811289,1,0,0,ebay_checkout,cc,cc,USD2659,USD0 
304a285281be,1383027928890968764,receiver,10C,655362,C2,USD811289,1,0,0,ebay_checkout,cc,cc,USD2659,GBP0 

樣本輸出

304a285281be,1383027928890968764,receiver,10C,655362,C2,USD811289,1,0,0,ebay_checkout,cc,cc,USD2659,USD0 
304a285281be,1383027928890968764,receiver,10C,655362,C2,USD811289,1,0,0,ebay_checkout,cc,cc,USD2659,GBP0 
+0

我的問題是chararray串轉換添加to_str($ 14),它就像一個魅力 –

回答

0

添加 '通過' 和 '('

X = FILTER C BY (FLATTEN($14) matches '.*USD.*'); 
    STORE X into '$output' using PigStorage(','); 
+0

它仍然does not工作對我來說,Itried與不FLATTEN –

+0

@FarheenNoorie後的樣本數據和預期的輸出和你的整個腳本 –

0

這是我用你的輸入工作之間的空間:

A = LOAD 'StackFile.txt' using PigStorage(','); 
B = FILTER A BY ($14 matches '.*USD.*'); 
DUMP B; 

塊引用

304a285281be,1383027928890968764,接收器, 10C,655362,C2,USD811289,1,0,0,ebay_checkout,cc,cc,USD2659,USD120 304a285281be,1383027928890968764,接收器,10C,655362,C2,USD811289,1,0,0,ebay_checkout,c C,CC,USD2659,USD0