0

我正在加载数据并创建一个元组:

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

后来我想重命名元组,这样我就有了

t: (f3: chararray, f4: chararray)

有没有可能?

4

1 回答 1

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)}
于 2013-11-04T17:26:18.870 回答