猪 - 错误 1045:AVG 为多个或不适合.请使用显式强制转换



我有一个逗号分隔.txt文件,我想DUMP所有MalesAVG年龄。

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);

相关内容

  • 没有找到相关文章

最新更新