piglatin重命名元组

fivyi3re  于 2021-06-25  发布在  Pig
关注(0)|答案(1)|浏览(305)

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

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

稍后我想重命名元组,所以我有

t: (f3: chararray, f4: chararray)

有可能吗?

4uqofj5v

4uqofj5v1#

您可以为复杂数据类型提供模式,就像为基本数据类型提供模式一样:

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)}

相关问题