我想写一个猪拉丁脚本:在这里我必须加载1951年之后的所有数据(不包括1951年),并过滤质量= 1的数据(按温度分组),然后计算每个年份的最大年份温度。
做到了
records = load '/user/a106524609/test.txt' using PigStorage(' ') as
(year:chararray, temperature:int, quality:int);
rec1 = filter records by year >1951 and (quality == 1);
答案 0 :(得分:1)
您正在将year加载到一个chararray字段中,并将其与1951年的int进行比较。您有两个选择。将year加载到int中,否则在过滤器语句中将year转换为int。
records = load '/user/a106524609/test.txt' using PigStorage(' ') as
(year:int, temperature:int, quality:int);
rec1 = filter records by year > 1951 and (quality == 1);
或
records = load '/user/a106524609/test.txt' using PigStorage(' ') as
(year:chararray, temperature:int, quality:int);
rec1 = filter records by year:int > 1951 and (quality == 1);-- Note (int)year > 1951 should work too