如果我对关系进行排序然后使用 LIMIT 它会失败并出现错误: 错误 1066:无法打开别名 oldest
的迭代器这里是输入数据,dataset.csv
John,27
Mary,31
David,45
Emily,22
Michael,38
Sarah,29
James,35
Jennifer,24
Robert,42
此版本运行没有错误并给出正确的结果:
data = LOAD 'dataset.csv' USING PigStorage(',') AS (name:chararray, age:int);
subdata = FOREACH data GENERATE name, age;
oldest = LIMIT subdata 5;
DUMP oldest;
但是在 Limit 之前添加 Sort 给了我那个错误。
data = LOAD 'dataset.csv' USING PigStorage(',') AS (name:chararray, age:int);
subdata = FOREACH data GENERATE name, age;
-- adding this next line causes LIMIT to fail
sorted_data = ORDER subdata BY age DESC;
oldest = LIMIT sorted_data 5;
DUMP oldest;