Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/hadoop/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Hadoop 清管器-错误1045:平均值为多个或不匹配。请使用显式强制转换_Hadoop_Mapreduce_Apache Pig_Bigdata - Fatal编程技术网

Hadoop 清管器-错误1045:平均值为多个或不匹配。请使用显式强制转换

Hadoop 清管器-错误1045:平均值为多个或不匹配。请使用显式强制转换,hadoop,mapreduce,apache-pig,bigdata,Hadoop,Mapreduce,Apache Pig,Bigdata,我有一个逗号分隔的.txt文件,我想转储AVG所有男性的年龄 records = LOAD 'file:/home/gautamshaw/Documents/PigDemo_CommaSep.txt' USING PigStorage(',') AS (firstname:chararray,lastname:chararray,age:int,sex:chararray); filter_by_male = FILTER records BY sex == 'M'; grouped = GRO

我有一个逗号分隔的.txt文件,我想
转储
AVG
所有
男性的
年龄

records = LOAD 'file:/home/gautamshaw/Documents/PigDemo_CommaSep.txt' USING PigStorage(',') AS (firstname:chararray,lastname:chararray,age:int,sex:chararray);
filter_by_male = FILTER records BY sex == 'M';
grouped = GROUP filter_by_male ALL;
average_male_age = FOREACH grouped GENERATE AVG(records.age);
我在
FOREACH
行中收到一个错误:

ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1045: 
<line 6, column 44> Could not infer the matching function for org.apache.pig.builtin.AVG as multiple or none of them fit. Please use an explicit cast.
ERROR org.apache.pig.tools.grunt.grunt-错误1045:
无法推断org.apache.pig.builtin.AVG的匹配函数有多个或没有匹配的函数。请使用显式强制转换。

请注意。

您不应投影
记录
关系,它应该是
按男性过滤
关系

你能像这样改变你的剧本吗

average_male_age = FOREACH grouped GENERATE AVG(filter_by_male.age);

您将数据按男性关系分组,而不是按记录关系分组。您可以键入“descripe grouped”查看结果。它将清楚地告诉您需要用于任何聚合操作的关系名称。