错误[main] 2997:无法从后端错误重新创建异常:org.apache.pig.backend.executionengine.ExecException

时间:2012-10-13 17:06:33

标签: apache-pig

我在pig中创建了以下脚本。我是PIG和PIGLATIN的新手。我还在学习如何有效地使用PIG脚本。

执行脚本时出现此错误:

  

错误ERROR [main] org.apache.pig.tools.grunt.Grunt - ERROR 2997:无法从后端错误重新创建异常:org.apache.pig.backend.executionengine.ExecException

有人可以解释原因以及我如何纠正它。在csv文件中,除了包含整数值的rate列之外,我有所有char列。

*divs = LOAD 'output\file.csv' using PigStorage(',') AS (uniID:chararray, deal:chararray, rol: chararray,name:chararray,add:chararray,city:chararray,stat:chararray,stn:chararray,zip:chararray,country:chararray,db:chararray,sm:chararray,rate:int);
DUMP divs;
trimmed = foreach divs generate sm,uniID,rol,rate,country;
DUMP trimmed;
grpd = group trimmed by sm;
orderd = order trimmed by country;
describe trimmed;
describe grpd;
DUMP grpd;
describe orderd;
avgdiv = foreach grpd generate sm, AVG(divs.rate), SUM(divs.rate), MAX(divs.rate);
DUMP avgdiv;
store avgdiv into 'output/pigdescribe1out';
explain;*

1 个答案:

答案 0 :(得分:1)

您的group语句返回错误。您正试图在分组之前聚合数据,因此错误。

divs = LOAD '$input' using PigStorage('^A') AS (uniID:chararray, deal:chararray, rol: chararray,name:chararray,add:chararray,city:chararray,stat:chararray,stn:chararray,zip:chararray,country:chararray,db:chararray,sm:chararray,rate:int);<br/>
DUMP divs;
trimmed = foreach divs generate sm,uniID,rol,rate,country;
DUMP trimmed;
grpd = group trimmed by sm;
orderd = order trimmed by country;
describe trimmed;
describe grpd;
DUMP grpd;
describe orderd;
avgdiv = foreach grpd generate FLATTEN(group), AVG(trimmed.rate), SUM(trimmed.rate), MAX(trimmed.rate);
DUMP avgdiv;
store avgdiv into 'data/sampledata/';
explain;

这完全没问题。