0
比方說,我有以下PIG腳本維護數據的順序在豬腳本
record = LOAD 'input' USING PigStorage('\t') as (id, name, age);
orderedRecord = ORDER record BY age ASC;
finalRecord = FOREACH orderedRecord GENERATE id,name;
storedRecords = LIMIT finalRecord 1000;
STORE storedRecords INTO 'output';
我知道orderedRecord將根據年齡進行排序,但是當我刪除年齡orderedRecord,數據是否仍然有序。我只是想存儲1000個數據點,只有id和姓名按年齡排序。
我已經得到了答案:爲了讓storeRecords按排序順序執行,我應該執行以下操作> record = LOAD'input'使用PigStorage('\ t')作爲(id,name,age); orderedRecord = ORDER記錄按年齡ASC; finalRecord = LIMIT finalRecord 1000; finalRecord = LIMIT finalRecord 1000; storedRecords = FOREACH orderedRecord GENERATE id,name; STORE storedRecords INTO'output'; – user2277149