2017-02-10 82 views
0

c1 = LOAD'hdfs:// localhost:9000/PigData/patient.txt'使用PigStorage(',') as(age:int,gender:chararray,郵政編碼:int);在c2 = LOAD'hdfs:// localhost:9000/PigData/att1'使用PigStorage(',')as(att:chararray,cnt:int); res = FOREACH c2生成$ 0;%聲明zip res。$ 0; final =通過$ zip編組c1; dump final;如何將關係的屬性轉換爲豬的字符串

我想atrribute存儲爲一個變量vaue,然後組變量的幫助下,數據他沒有直接提到值..

+0

資源關係的值爲(ZIPC ode),我想用這個res值組合c1關係。 %聲明郵政編碼$ 0;我試着用這段代碼,但是我在這裏得到錯誤。 –

回答

0

前綴與(chararray)。假設你的屬性想投郵政編碼按郵政編碼來string.See here流延文件

c2 = FOREACH c1 GENERATE c1.age,c1.gender,(chararray)c1.zipcode; 
DESCRIBE C2; 

集團

c1 = LOAD 'hdfs://localhost:9000/PigData/patient.txt' USING PigStorage(',') as (age:int,gender:chararray,zipcode:int); 
c2 = LOAD 'hdfs://localhost:9000/PigData/att1' USING PigStorage(',') as (att:chararray,cnt:int); 
final = group c1 by c1.zipcode; 
dump final; 
+0

謝謝你的回覆 –

+0

@RPadmaja你不需要這樣的說法。只需使用郵編分組即可。 –

相關問題