2013-11-04 40 views
0

我加載數據,並創建一個元組:PigLatin重命名元組

data = LOAD 'file' USING PigStorage(';') AS (f1: chararray, f2: chararray); 
t = FOREACH data GENERATE TOTUPLE(f1, f1) as t; 

後來我要重命名的元組式,因此我有

t: (f3: chararray, f4: chararray) 

是否有可能?

回答

1

您可以爲複雜的數據類型的模式就像你的基本要點:

grunt> data = LOAD 'file' USING PigStorage(';') AS (f1: chararray, f2: chararray); 
grunt> t = FOREACH data GENERATE TOTUPLE(f1, f1) as t; 
grunt> DESCRIBE t; 
t: {t: (f1: chararray,f1: chararray)} 
grunt> t = FOREACH t GENERATE t AS t:tuple(f3:chararray, f4:chararray); 
grunt> DESCRIBE t; 
t: {t: (f3: chararray,f4: chararray)} 

如果你願意,你可以省略tuple關鍵字:

grunt> t = FOREACH t GENERATE t AS t:(f5:chararray, f6:chararray); 
grunt> DESCRIBE t; 
t: {t: (f5: chararray,f6: chararray)}