Krishna Shah
Krishna Shah

Reputation: 9

Not getting calculated value with SUM() in pig

My commands are as under:

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);

I am getting the output of

DUMP R;

as :

{all,()};

Please guide me. TIA.

Upvotes: 1

Views: 49

Answers (1)

nobody
nobody

Reputation: 11080

You need to use GROUP ALL instead of GROUP BY to get the 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;

Upvotes: 0

Related Questions