猪 - 错误 1045:AVG 为多个或 none 个适合。请使用显式转换
Pig - ERROR 1045: AVG as multiple or none of them fit. Please use an explicit cast
我有一个逗号分隔的 .text 文件,我想 DUMP
所有 Males
.
的 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.
请指教
你不应该投射 records
关系,它应该是 filter_by_male
关系。
你能把脚本改成这样吗?
average_male_age = FOREACH grouped GENERATE AVG(filter_by_male.age);
我有一个逗号分隔的 .text 文件,我想 DUMP
所有 Males
.
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.
请指教
你不应该投射 records
关系,它应该是 filter_by_male
关系。
你能把脚本改成这样吗?
average_male_age = FOREACH grouped GENERATE AVG(filter_by_male.age);