Pig Latin中的AVG()函数问题

时间:2018-03-21 15:54:04

标签: hadoop apache-pig

我正在尝试生成数据集中列出的演出(double)的AVG()。我收到一个ERROR 1066: Unable to open iterator for alias TEST异常,我认为这是因为TEST为空且无法迭代。

flat_bus = FOREACH buss GENERATE near, name, FLATTEN(categories) AS category, stars;

bus_grouped = GROUP flat_bus BY category;

category_avg = FOREACH bus_grouped GENERATE group as grp, AVG(bus_grouped.stars);

TEST = LIMIT category_avg 10;

DUMP TEST;

我测试了群组功能并成功转储,如下所示: enter image description here

1 个答案:

答案 0 :(得分:1)

应该从flat_bus获得明星

category_avg = FOREACH bus_grouped GENERATE group as grp, AVG(flat_bus.stars);