APACHE PIG - 模式中不存在错误投影字段 [Units_Sold]:group:chararray,D2:bag:tuple(Item_Type:chararray,Units_Sold:i
Posted
技术标签:
【中文标题】APACHE PIG - 模式中不存在错误投影字段 [Units_Sold]:group:chararray,D2:bag:tuple(Item_Type:chararray,Units_Sold:int)【英文标题】:APACHE PIG - error Projected field [Units_Sold] does not exist in schema: group:chararray,D2:bag:tuple(Item_Type:chararray,Units_Sold:int)APACHE PIG - 模式中不存在错误投影字段 [Units_Sold]:group:chararray,D2:bag:tuple(Item_Type:chararray,Units_Sold:int) 【发布时间】:2021-08-13 17:07:17 【问题描述】:下午好 - 我有一个销售数据集,我正在尝试查看哪个商品的销量最多。 这是我的代码:
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
【问题讨论】:
【参考方案1】:SUM 正在等待一个袋子。错误显示了架构:
D2:bag:tuple(Item_Type:chararray,Units_Sold:int)
因此将 SUM 更改为:
SUM(D2.Units_Sold)
【讨论】:
以上是关于APACHE PIG - 模式中不存在错误投影字段 [Units_Sold]:group:chararray,D2:bag:tuple(Item_Type:chararray,Units_Sold:i的主要内容,如果未能解决你的问题,请参考以下文章
pig - 将数据从行转换为列,同时为特定行中不存在的字段插入占位符