以下关系
H = foreach G generate word,date;
这是我在PIG中的数据。
(sick,21-05-2013)
(sick,21-05-2013)
(sick,21-05-2013)
(sick,17-05-2013)
(sick,19-05-2013)
(sickness,21-05-2013)
(sickness,21-05-2013)
(sickness,21-05-2013)
(sickness,17-05-2013)
(sickness,19-05-2013)
我应该编写什么脚本才能将输出作为
(sick,21-05-2013,3)
(sick,17-05-2013,1)
(sick,19-05-2013,1)
(sickness,21-05-2013,3)
(sickness,17-05-2013,1)
(sickness,19-05-2013,1)
我完全感到困惑,无法绞尽脑汁。救命啊!
答案 0 :(得分:0)
这将给出我需要的结果
I = Group H by (word,date);
J = FOREACH I generate group,COUNT($1);
dump J;