Pig中除法的无效字段项目

时间:2016-06-08 17:35:17

标签: hadoop apache-pig

我正在尝试对猪的COUNT的结果进行2列的划分:

a = LOAD 'file.csv' USING PigStorage(',') AS (ID:chararray, Name:chararray, Result:chararray)
b = filter a by $1=='123';
c = filter a by $1=='123' and $2='Win';
d = foreach (group b by $1) generate group as da_id, count(b) as total;
e = foreach (group c by $1) generate group as da_id, count(c) as total_wins;
f = join d by da_id, e by da_id;
g = foreach (group f by $0) generate group as da_id, f::total_wins/f::total as ratio;

然而,我收到错误

Invalid field projection. Projected field [f::total_wins] does not exist in schema

有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

total和total_wins分别是关系d和e的一部分。使用下面的代码

g = foreach (group f by $0) generate group as da_id, e::total_wins/d::total as ratio;