pig中division的字段项目无效

nom7f22z  于 2021-06-02  发布在  Hadoop
关注(0)|答案(1)|浏览(242)

我试着做一个2列的划分,这是 COUNT 在清管器中:

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

有人能帮忙吗?

mepcadol

mepcadol1#

total和total\ u wins分别是关系d和e的一部分。请使用下面的代码

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

相关问题