Hadoop 分组数据抛出错误1046上的平均值:使用显式强制转换

Hadoop 分组数据抛出错误1046上的平均值:使用显式强制转换,hadoop,mapreduce,apache-pig,bigdata,Hadoop,Mapreduce,Apache Pig,Bigdata,我有一个txt文件中的映射: [age#27,height#5.8] [age#25,height#5.3] [age#27,height#5.10] [age#25,height#5.1] 我想显示每个年龄组的平均身高 这是LAOD语句: records = LOAD '~/Documents/Pig_Map.txt' AS (details:map[]); records: {details: map[]} 然后,我根据年龄对数据进行分组: group_data = GROUP reco

我有一个txt文件中的
映射

[age#27,height#5.8]
[age#25,height#5.3]
[age#27,height#5.10]
[age#25,height#5.1]
我想显示每个年龄组的平均身高

这是
LAOD
语句:

records = LOAD '~/Documents/Pig_Map.txt' AS (details:map[]);
records: {details: map[]}
然后,我根据年龄对数据进行分组:

group_data = GROUP records BY details#'age';
group_data: {group: bytearray,records: {(details: map[])}}
为了访问
详细信息
我做了如下
展平
(不确定是否需要此步骤):

DUMP flant\u记录
这将为我提供以下输出:

(25,[height#5.1,age#25])
(25,[height#5.3,age#25])
(27,[height#5.10,age#27])
(27,[height#5.8,age#27])
现在我想得到平均身高;我试过这个:

display_records = FOREACH flatten_records GENERATE group,AVG(records.details#'height');
错误是:

<line 10, column 57> Multiple matching functions for org.apache.pig.builtin.AVG with input schema: ({{(bytearray)}}, {{(double)}}). Please use an explicit cast.
org.apache.pig.builtin.AVG的多个匹配函数,输入模式:({(bytearray)}},{(double)})。请使用显式强制转换。 请给出建议。

你能试试这个吗

records = LOAD '~/Documents/Pig_Map.txt' AS (details:map[]);
records1 = FOREACH records GENERATE details#'age' AS age,details#'height' AS height;
group_data = GROUP records1 BY age;
display_records = FOREACH group_data GENERATE group,AVG(records1.height);
dump display_records;
输出:

(25,5.199999999999999)
(27,5.449999999999999)
(25,5.199999999999999)
(27,5.449999999999999)