我有一个关系reflat1。以下是DESCRIBE和DUMP的输出。PIG:无法将(key,(tuple_of_3_things))转换为(key,tupelement1,tupelement2,tupelement3)
reflat1: {cookie: chararray,tupofstuff: (category: chararray,weight: double,lasttime: long)}
(key1,(613,1.0,1410155702)
(key2,(iOS,1.0,1410155702)
(key3,(G.M.,1.0,1410155702)
是的,我注意到括号没有关闭。我不知道为什么。也许没有括号的原因是我所有问题的根源。
我想将它转换成一个关系(我们称之为reflat2)有4场,这将理想样子:
(key1, 613, 1.0,1410155702)
(key2, iOS, 1.0,1410155702)
(key3, G.M., 1.0,1410155702)
但我的代码是行不通的。以下是相关位。
reflat2 = foreach reflat1 {
GENERATE
cookie as cookie,
tupofstuff.(category) as category,
tupofstuff.(weight) as weight,
tupofstuff.(lasttime) as lasttime;
};
r1 = LIMIT reflat2 100;
dump r1;
导致的模式,我期望:
DESCRIBE reflat2
reflat2: {cookie: chararray,category: chararray,weight: double,lasttime: long}
但在转储给出了一个错误:
Unable to open iterator for alias r1
当我看到这些错误的失败MapReduce作业,我看到:
java.lang.ClassCastException: java.lang.String cannot be cast to org.apache.pig.data.Tuple
Whic h是很奇怪的,因为如果有什么我要将一个元组投射到一个字符串(以及一个双精度和一个长精度),反之亦然。
对于在寻找[错误1066:无法打开迭代器别名]时发现此帖子的人(http://stackoverflow.com/questions/34495085/error-1066-unable-to-open-iterator-for- alias-in-pig-generic-solution)这里是一个[通用解决方案](http://stackoverflow.com/a/34495086/983722)。 – 2015-12-28 14:54:23