我正在加载数据并创建一个元组:
data = LOAD 'file' USING PigStorage(';') AS (f1: chararray, f2: chararray);
t = FOREACH data GENERATE TOTUPLE(f1, f1) as t;
后来我想重命名Tuple,我有
t: (f3: chararray, f4: chararray)
有可能吗?
答案 0 :(得分: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)}