在pig中加载数据时出错

cfh9epnr  于 2021-05-29  发布在  Hadoop
关注(0)|答案(1)|浏览(392)

我想写一个Pig拉丁脚本:在那里我必须加载1951年(不包括1951年)之后的所有数据,并过滤数据,其中quality=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);

我得到这个错误

xfb7svmp

xfb7svmp1#

您正在将年份加载到chararray字段,并将其与1951(int)进行比较。您有两个选择:将年份加载到int或在filter语句中将年份强制转换为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

相关问题