我有一个非常简单的 2 列数据,带有一个 double 和一个 chararray:
user1 234.43
user1 432.23
user2 4321.213
etc.
我想按用户分组,然后计算他们双打的平均值。如何?我需要“GROUP * ALL”吗?我正在尝试遵循示例 2 http://wiki.apache.org/pig/PigOverview,但它对我不起作用。
selfReportsAndDiscrepancies = FOREACH discrepancies1 GENERATE discrepancy,selfReportedText;
perDiscrepancy = GROUP selfReportsAndDiscrepancies BY selfReportedText;
allDiscrep = group perDiscrepancy all;
means = FOREACH allDiscrep GENERATE AVG(perDiscrepancy.discrepancy);
DUMP means;
DESCRIBE means;
给我:
2013-04-02 17:54:06,611 [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1128: Cannot find field discrepancy in group:chararray,selfReportsAndDiscrepancies:bag{:tuple(discrepancy:double,selfReportedText:chararray)}