没有得到猪的SUM()计算值

时间:2017-07-19 08:55:28

标签: hadoop sum apache-pig

我的命令如下:

Z = LOAD '/..file_path' USING PigStorage(',') AS (name:CHARARRAY,gpa:int,salary:int);
y = GROUP Z BY gpa;
R = FOREACH y GENERATE SUM(Z.salary);

我得到了

的输出
DUMP R;

as:

{all,()};

请指导我。 TIA。

1 个答案:

答案 0 :(得分:0)

您需要使用GROUP ALL而不是GROUP BY来获取SUM

Z = LOAD '/..file_path' USING PigStorage(',') AS (name:CHARARRAY,gpa:int,salary:int);
y = GROUP Z ALL;
R = FOREACH y GENERATE SUM(Z.salary);
DUMP R;