1
比方說,我有以下計算SUM
DATA = foreach INPUT {
//..
generate group, count(name) as total;
}
我會在那裏,關鍵是按名稱
('mike', 'someprop', 10)
('mike', 'otherprop', 3)
('doug', 'xprop', 5)
...
分組的關係結束了,我想要得到的總和每個名稱的前10名:
ALIAS = group DATA by name;
RESULT = foreach ALIAS {
SORTED = ORDER DATA by total desc;
TOP10 = LIMIT SORTED 10;
//doesn't work! can't have GROUP inside FOREACH
AGG = group TOP10 ALL;
TOPTOTAL = foreach AGG generate SUM(AGG.total);
generate group, TOPTOTAL;
}
如何計算一個值(SUM,COUNT,ETC)關係內foreach
?目前無法在foreach中應用GROUP ALL
。