2012-06-08 29 views
3
領域

我有以下的豬腳本:
我的文件1.txt的具有 A 1
B 2
的C 3
d 4訪問元組

grunt> A = load '1.txt' using PigStorage(' ') as (a:chararray,b:int); 
grunt> B = foreach A generate A.a; 
grunt> dump B; 

它給了我下面的錯誤

ERROR org.apache.pig.tools.grunt.Grunt - 錯誤2997:無法重新創建支持錯誤的異常:org.apache.pig.backend.executionengine.ExecException:錯誤0:標量有輸出中有多行。 1st:(A,1),2nd:(B,2)

回答

6

您不必將a設置爲A.a。試試這個:

grunt> A = load '1.txt' using PigStorage(' ') as (a:chararray,b:int); 
grunt> B = foreach A generate a; 
grunt> dump B; 

C.x是抓住一個「列」從包裏拿出來。假設C是一件物品,那麼C.x將創建一個包中所有x的新包。這不是你想要的。 foreach在這裏爲你重複穿過這個包。

+0

謝謝orangeoctopus。 – Uno