0
我有一個非常簡單的2列數據,一張雙人牀和一個chararray:豬羣中的簡單AVG?
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)}
謝謝。我有一個錯誤(我有一個UDF是附加字符串,它應該是雙打)。這確實有用。 – dranxo