我有一个逗号分隔的.txt文件,我想 DUMP
这个 AVG
所有人的年龄 Males
.
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.
请给我建议。
1条答案
按热度按时间csga3l581#
你不应该投射
records
应该是什么关系filter_by_male
关系。你能这样改剧本吗?