Siyin Yang
Siyin Yang

Reputation: 21

PIG ERROR 1070 when Count grouped data

I just want to count how many player for each team in 2011. It works good when group it with tmID. However, when I try to count the grouped data, the ERROR 1070 comes out.

    load_file = load 'Assignment2/basketball_players.csv' using PigStorage(',');
temp = foreach load_file generate
    (chararray)$3 AS tmID,
    (int)$1 AS year, 
    (chararray)$0 AS playerID;
fil_data = filter temp by year == 2011;
group_data = group fil_data by tmID;
count_data = foreach group_data generate group, count($1);
dump count_data;

the error message shows below.

<file script.pig, line 8, column 48> Failed to generate logical plan. Nested exception: org.apache.pig.backend.executionengine.ExecException: ERROR 1070: Could not resolve count using imports: [, java.lang., org.apache.pig.builtin., org.apache.pig.impl.builtin.]

Could anyone could help me for this problem? THX

Upvotes: 2

Views: 500

Answers (2)

Rajesh M
Rajesh M

Reputation: 11

All functions need to be in UPPER case. Commands like foreach, generate group by etc can be in either case.

Upvotes: 1

Murali Rao
Murali Rao

Reputation: 2287

COUNT function is case sensitive. Ref : http://pig.apache.org/docs/r0.12.0/func.html#count

Try this :

count_data = foreach group_data generate group, COUNT($1);

instead of $1 would suggest to make use of alias fil_data as its more readable.

Upvotes: 2

Related Questions