2014-02-24 24 views
1

我有一個包含一個文件max_rank.txt:豬拉丁 - 從不同袋中增加價值?

1,a 
2,b 
3,c 

和第二個文件max_rank_add.txt:

d 
e 
f 

我期待的結果是:

1,a 
2,b 
3,c, 
4,d, 
5,e 
6,f 

所以我要生成RANK對於第二組值,但是從大於第一組的值開始。

腳本的Beginig大概是這樣的:

existing = LOAD 'max_rank.txt' using PigStorage(',') AS (id: int, text : chararray); 
new = LOAD 'max_rank_add.txt' using PigStorage() AS (text2 : chararray); 
ordered = ORDER existing by id desc; 
limited = LIMIT ordered 1; 
new_rank = RANK new; 

但我有最後一個,最importatn線,即增加值從limitedrank_newnew_rank問題。

你可以給點建議嗎?

問候 帕維爾

回答

0

我已經找到了解決辦法。 兩個腳本工作:

rank_plus_max = foreach new_rank generate flatten(limited.$0 + rank_new), text2; 
rank_plus_max = foreach new_rank generate limited.$0 + rank_new, text2; 

這些不工作:

rank_plus_max = foreach new_rank generate flatten(limited.$0) + flatten(rank_new); 

2014-02-24 10:52:39,580 [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1200: <line 10, column 62> mismatched input '+' expecting SEMI_COLON 
Details at logfile: /export/home/pig/pko/pig_1393234166538.log