0

下午好 - 我有一个销售数据集,我正在尝试查看哪个商品的销量最多。这是我的代码:

        Country:chararray,
        Item_Type:chararray,
        Sales_Channel:chararray,
        Order_Priority_site:chararray,
        Order_Date:chararray,
        Order_ID:chararray,
        Ship_Date:chararray,
        Units_Sold:int,
        Unit_Price: int,
        Unit_Cost: int,
        Total_Revenue: int,
        Total_Cost: int,
        Total_Profit:int);

D2 = FOREACH data GENERATE Item_Type, Units_Sold;

D3 = GROUP D2 BY Item_Type;

D4 = FOREACH D3 GENERATE group, SUM(Units_Sold);

DUMP D4;```

However, I get the error: 

```<file D, line 20, column 36> Invalid field projection. Projected field [Units_Sold] does not exist in schema: group:chararray,D2:bag{:tuple(Item_Type:chararray,Units_Sold:int)}.```

Does anybody know how to fix this? Let me know if you need more info, this is the first qurstion I have posted on here
4

1 回答 1

0

SUM 正在等待一个袋子。该错误向您显示架构:

D2:bag{:tuple(Item_Type:chararray,Units_Sold:int)}

因此将 SUM 更改为:

SUM(D2.Units_Sold)

于 2021-08-14T07:09:43.803 回答