计数分组数据时出现错误1070

ni65a41a  于 2021-06-24  发布在  Pig
关注(0)|答案(2)|浏览(407)

我只想统计一下2011年每支球队有多少球员。将其与tmid组合时效果良好。但是,当我尝试计算分组数据时,出现了错误1070。

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;

错误消息如下所示。

<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.]

有人能帮我解决这个问题吗?谢谢

a8jjtwal

a8jjtwal1#

计数函数区分大小写。裁判:http://pig.apache.org/docs/r0.12.0/func.html#count
试试这个:

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

建议使用alias fil\ u数据而不是1美元,因为它更具可读性。

lvjbypge

lvjbypge2#

所有函数都需要大写。foreach、generate group by等命令都可以在这两种情况下使用。

相关问题